Merge "bionic/test: migrate sysconf tests from system/extras to bionic/tests"
diff --git a/libc/Android.mk b/libc/Android.mk
index 7d438f4..3e37ca7 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -548,13 +548,6 @@
libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT)
endif
-# Define ANDROID_SMP appropriately.
-ifeq ($(TARGET_CPU_SMP),true)
- libc_common_cflags += -DANDROID_SMP=1
-else
- libc_common_cflags += -DANDROID_SMP=0
-endif
-
# Define some common conlyflags
libc_common_conlyflags := \
-std=gnu99
diff --git a/libc/private/bionic_atomic_arm.h b/libc/private/bionic_atomic_arm.h
index 2156e6a..0cb832f 100644
--- a/libc/private/bionic_atomic_arm.h
+++ b/libc/private/bionic_atomic_arm.h
@@ -17,12 +17,7 @@
#define BIONIC_ATOMIC_ARM_H
__ATOMIC_INLINE__ void __bionic_memory_barrier() {
-#if defined(ANDROID_SMP) && ANDROID_SMP == 1
__asm__ __volatile__ ( "dmb ish" : : : "memory" );
-#else
- /* A simple compiler barrier. */
- __asm__ __volatile__ ( "" : : : "memory" );
-#endif
}
/* Compare-and-swap, without any explicit barriers. Note that this function
diff --git a/libc/private/bionic_atomic_inline.h b/libc/private/bionic_atomic_inline.h
index b834a27..f8032c3 100644
--- a/libc/private/bionic_atomic_inline.h
+++ b/libc/private/bionic_atomic_inline.h
@@ -30,10 +30,6 @@
* on SMP systems emits an appropriate instruction.
*/
-#if !defined(ANDROID_SMP)
-# error "Must define ANDROID_SMP before including atomic-inline.h"
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/libc/private/bionic_atomic_mips.h b/libc/private/bionic_atomic_mips.h
index 5e08116..83f75fe 100644
--- a/libc/private/bionic_atomic_mips.h
+++ b/libc/private/bionic_atomic_mips.h
@@ -21,12 +21,7 @@
*/
__ATOMIC_INLINE__ void __bionic_memory_barrier() {
-#if defined(ANDROID_SMP) && ANDROID_SMP == 1
__asm__ __volatile__ ( "sync" : : : "memory" );
-#else
- /* A simple compiler barrier. */
- __asm__ __volatile__ ( "" : : : "memory" );
-#endif
}
/* Compare-and-swap, without any explicit barriers. Note that this function
diff --git a/libc/private/bionic_atomic_x86.h b/libc/private/bionic_atomic_x86.h
index 89639c8..e63df93 100644
--- a/libc/private/bionic_atomic_x86.h
+++ b/libc/private/bionic_atomic_x86.h
@@ -20,12 +20,7 @@
* platform for a multi-core device.
*/
__ATOMIC_INLINE__ void __bionic_memory_barrier() {
-#if defined(ANDROID_SMP) && ANDROID_SMP == 1
__asm__ __volatile__ ( "mfence" : : : "memory" );
-#else
- /* A simple compiler barrier. */
- __asm__ __volatile__ ( "" : : : "memory" );
-#endif
}
/* Compare-and-swap, without any explicit barriers. Note that this function
diff --git a/tests/Android.build.mk b/tests/Android.build.mk
index 9c5df0e..0754a7b 100644
--- a/tests/Android.build.mk
+++ b/tests/Android.build.mk
@@ -35,7 +35,10 @@
endif
LOCAL_CLANG := $($(module)_clang_$(build_type))
+
+ifneq ($($(module)_allow_asan),true)
LOCAL_ADDRESS_SANITIZER := false
+endif
LOCAL_FORCE_STATIC_EXECUTABLE := $($(module)_force_static_executable)
diff --git a/tests/Android.mk b/tests/Android.mk
index 967ddbd..92d7976 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -317,6 +317,8 @@
bionic-unit-tests-glibc_cppflags := $(test_cppflags)
bionic-unit-tests-glibc_ldflags := -Wl,--export-dynamic
+bionic-unit-tests-glibc_allow_asan := true
+
module := bionic-unit-tests-glibc
module_tag := optional
build_type := host
diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp
index ef2c8da..0cebe4e 100644
--- a/tests/netdb_test.cpp
+++ b/tests/netdb_test.cpp
@@ -21,6 +21,23 @@
#include <netdb.h>
#include <netinet/in.h>
+TEST(netdb, getaddrinfo_NULL_host) {
+ // It's okay for the host argument to be NULL, as long as service isn't.
+ addrinfo* ai = NULL;
+ ASSERT_EQ(0, getaddrinfo(NULL, "smtp", NULL, &ai));
+ // (sockaddr_in::sin_port and sockaddr_in6::sin6_port overlap.)
+ ASSERT_EQ(25U, ntohs(reinterpret_cast<sockaddr_in*>(ai->ai_addr)->sin_port));
+ freeaddrinfo(ai);
+}
+
+TEST(netdb, getaddrinfo_NULL_service) {
+ // It's okay for the service argument to be NULL, as long as host isn't.
+ addrinfo* ai = NULL;
+ ASSERT_EQ(0, getaddrinfo("localhost", NULL, NULL, &ai));
+ ASSERT_TRUE(ai != NULL);
+ freeaddrinfo(ai);
+}
+
TEST(netdb, getaddrinfo_NULL_hints) {
addrinfo* ai = NULL;
ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai));