Merge "Fix some easy cases of __ANDROID__ versus __BIONIC__."
diff --git a/libc/bionic/brk.cpp b/libc/bionic/brk.cpp
index a8c078b..e1a4b05 100644
--- a/libc/bionic/brk.cpp
+++ b/libc/bionic/brk.cpp
@@ -29,7 +29,7 @@
#include <errno.h>
#include <unistd.h>
-#if __LP64__
+#if defined(__LP64__)
static void* __bionic_brk;
#else
void* __bionic_brk; // Accidentally exported by the NDK.
diff --git a/libc/bionic/fpclassify.cpp b/libc/bionic/fpclassify.cpp
index f8cea80..42ed3ef 100644
--- a/libc/bionic/fpclassify.cpp
+++ b/libc/bionic/fpclassify.cpp
@@ -113,7 +113,7 @@
}
__strong_alias(isnormalf, __isnormalf);
-#if __LP64__
+#if defined(__LP64__)
// LP64 uses 128-bit long doubles.
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index f2bb37d..983fb32 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -37,7 +37,7 @@
#include <sys/vfs.h>
#include <unistd.h>
-#if __LP64__
+#if defined(__LP64__)
#error This code is only needed on 32-bit systems!
#endif
diff --git a/libc/bionic/open.cpp b/libc/bionic/open.cpp
index 41dce43..2daa21f 100644
--- a/libc/bionic/open.cpp
+++ b/libc/bionic/open.cpp
@@ -36,7 +36,7 @@
extern "C" int __openat(int, const char*, int, int);
static inline int force_O_LARGEFILE(int flags) {
-#if __LP64__
+#if defined(__LP64__)
return flags; // No need, and aarch64's strace gets confused.
#else
return flags | O_LARGEFILE;
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 58aa6f1..bfa4e8c 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -44,7 +44,7 @@
#include "private/ScopedPthreadMutexLocker.h"
// x86 uses segment descriptors rather than a direct pointer to TLS.
-#if __i386__
+#if defined(__i386__)
#include <asm/ldt.h>
void __init_user_desc(struct user_desc*, bool, void*);
#endif
@@ -101,7 +101,7 @@
sched_param param;
param.sched_priority = thread->attr.sched_priority;
if (sched_setscheduler(thread->tid, thread->attr.sched_policy, ¶m) == -1) {
-#if __LP64__
+#if defined(__LP64__)
// For backwards compatibility reasons, we only report failures on 64-bit devices.
error = errno;
#endif
diff --git a/libc/bionic/statvfs.cpp b/libc/bionic/statvfs.cpp
index 39ffb64..cd825eb 100644
--- a/libc/bionic/statvfs.cpp
+++ b/libc/bionic/statvfs.cpp
@@ -20,7 +20,7 @@
// Paper over the fact that 32-bit kernels use fstatfs64/statfs64 with an extra argument,
// but 64-bit kernels don't have the "64" bit suffix or the extra size_t argument.
-#if __LP64__
+#if defined(__LP64__)
extern "C" int __fstatfs(int, struct statfs*);
extern "C" int __statfs(const char*, struct statfs*);
# define __fstatfs64(fd,size,buf) __fstatfs(fd,buf)
diff --git a/libc/bionic/strtold.cpp b/libc/bionic/strtold.cpp
index 5616cf7..c55dd61 100644
--- a/libc/bionic/strtold.cpp
+++ b/libc/bionic/strtold.cpp
@@ -32,7 +32,7 @@
extern "C" int __strtorQ(const char*, char**, int, void*);
long double strtold(const char* s, char** end_ptr) {
-#if __LP64__
+#if defined(__LP64__)
long double result;
__strtorQ(s, end_ptr, FLT_ROUNDS, &result);
return result;
diff --git a/libc/include/link.h b/libc/include/link.h
index f40e7e4..92ecceb 100644
--- a/libc/include/link.h
+++ b/libc/include/link.h
@@ -34,7 +34,7 @@
__BEGIN_DECLS
-#if __LP64__
+#if defined(__LP64__)
#define ElfW(type) Elf64_ ## type
#else
#define ElfW(type) Elf32_ ## type
diff --git a/libc/include/netinet/ip6.h b/libc/include/netinet/ip6.h
index 639637e..fcfd5d6 100644
--- a/libc/include/netinet/ip6.h
+++ b/libc/include/netinet/ip6.h
@@ -66,6 +66,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+#include <endian.h>
#include <linux/in6.h>
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index 1cedca1..322a81c 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -39,7 +39,7 @@
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
-#if __LP64__
+#if defined(__LP64__)
typedef long __int64_t;
typedef unsigned long __uint64_t;
#else
@@ -47,7 +47,7 @@
typedef unsigned long long __uint64_t;
#endif
-#if __LP64__
+#if defined(__LP64__)
typedef long __intptr_t;
typedef unsigned long __uintptr_t;
#else
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 13c3269..3b058e8 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -229,7 +229,7 @@
#include <android/api-level.h>
/* glibc compatibility. */
-#if __LP64__
+#if defined(__LP64__)
#define __WORDSIZE 64
#else
#define __WORDSIZE 32
@@ -278,7 +278,7 @@
#include <android/versioning.h>
#if __has_builtin(__builtin_umul_overflow) || __GNUC__ >= 5
-#if __LP64__
+#if defined(__LP64__)
#define __size_mul_overflow(a, b, result) __builtin_umull_overflow(a, b, result)
#else
#define __size_mul_overflow(a, b, result) __builtin_umul_overflow(a, b, result)
diff --git a/libc/include/sys/user.h b/libc/include/sys/user.h
index 5601b02..f9ad956 100644
--- a/libc/include/sys/user.h
+++ b/libc/include/sys/user.h
@@ -38,7 +38,7 @@
#define PAGE_SIZE 4096
#define PAGE_MASK (~(PAGE_SIZE - 1))
-#if __i386__
+#if defined(__i386__)
struct user_fpregs_struct {
long cwd;
diff --git a/libc/private/bionic_ieee.h b/libc/private/bionic_ieee.h
index c579969..69095f0 100644
--- a/libc/private/bionic_ieee.h
+++ b/libc/private/bionic_ieee.h
@@ -79,7 +79,7 @@
unsigned dbl_sign:1;
};
-#if __LP64__
+#if defined(__LP64__)
/* 64-bit Android uses ld128 long doubles. */
diff --git a/libc/upstream-openbsd/android/include/arith.h b/libc/upstream-openbsd/android/include/arith.h
index b262e4f..cb116d4 100644
--- a/libc/upstream-openbsd/android/include/arith.h
+++ b/libc/upstream-openbsd/android/include/arith.h
@@ -16,7 +16,7 @@
#define IEEE_8087
-#if __LP64__
+#if defined(__LP64__)
#define Long int
#endif
diff --git a/libc/upstream-openbsd/android/include/gd_qnan.h b/libc/upstream-openbsd/android/include/gd_qnan.h
index e5bf973..bcdff28 100644
--- a/libc/upstream-openbsd/android/include/gd_qnan.h
+++ b/libc/upstream-openbsd/android/include/gd_qnan.h
@@ -23,7 +23,7 @@
#define d_QNAN0 0x00000000
#define d_QNAN1 0x7ff80000
-#if __LP64__
+#if defined(__LP64__)
#define ld_QNAN0 0x00000000
#define ld_QNAN1 0x00000000
#define ld_QNAN2 0x00000000
diff --git a/tests/Android.bp b/tests/Android.bp
index ed42bde..defd76c 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -261,6 +261,37 @@
},
}
+cc_test_library {
+ name: "libBionicLoaderTests",
+ defaults: ["bionic_tests_defaults"],
+ srcs: [
+ "atexit_test.cpp",
+ "dl_test.cpp",
+ "dlfcn_test.cpp",
+ "pthread_dlfcn_test.cpp",
+ ],
+ static_libs: [
+ "libbase",
+ ],
+ include_dirs: [
+ "bionic/libc",
+ ],
+ shared: {
+ enabled: false,
+ },
+ target: {
+ android: {
+ srcs: [
+ "dlext_test.cpp",
+ "libdl_test.cpp",
+ ],
+ static_libs: [
+ "libpagemap",
+ ],
+ }
+ }
+}
+
// -----------------------------------------------------------------------------
// Library of bionic customized gtest main function, with normal gtest output format,
// which is needed by bionic cts test.
@@ -288,6 +319,7 @@
whole_static_libs: [
"libBionicTests",
+ "libBionicLoaderTests",
"libBionicGtestMain",
],
@@ -299,13 +331,7 @@
srcs: [
// TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
- "atexit_test.cpp",
- "dl_test.cpp",
- "dlext_test.cpp",
"__cxa_thread_atexit_test.cpp",
- "dlfcn_test.cpp",
- "libdl_test.cpp",
- "pthread_dlfcn_test.cpp",
"thread_local_test.cpp",
],
@@ -322,7 +348,6 @@
android: {
shared_libs: [
"libdl",
- "libpagemap",
"libdl_preempt_test_1",
"libdl_preempt_test_2",
"libdl_test_df_1_global",
@@ -330,6 +355,7 @@
static_libs: [
// The order of these libraries matters, do not shuffle them.
"libbase",
+ "libpagemap",
"libziparchive",
"libz",
"libutils",
diff --git a/tests/libc_logging_test.cpp b/tests/libc_logging_test.cpp
index d4ceded..4150483 100644
--- a/tests/libc_logging_test.cpp
+++ b/tests/libc_logging_test.cpp
@@ -133,7 +133,7 @@
#if defined(__BIONIC__)
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
-#if __LP64__
+#if defined(__LP64__)
EXPECT_STREQ("9223372036854775807", buf);
#else
EXPECT_STREQ("2147483647", buf);
@@ -147,7 +147,7 @@
#if defined(__BIONIC__)
char buf[BUFSIZ];
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
-#if __LP64__
+#if defined(__LP64__)
EXPECT_STREQ("-9223372036854775808", buf);
#else
EXPECT_STREQ("-2147483648", buf);
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 79c5e92..63da9e0 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -548,7 +548,7 @@
TEST(STDIO_TEST, snprintf_ld_LONG_MAX) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MAX);
-#if __LP64__
+#if defined(__LP64__)
EXPECT_STREQ("9223372036854775807", buf);
#else
EXPECT_STREQ("2147483647", buf);
@@ -558,7 +558,7 @@
TEST(STDIO_TEST, snprintf_ld_LONG_MIN) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%ld", LONG_MIN);
-#if __LP64__
+#if defined(__LP64__)
EXPECT_STREQ("-9223372036854775808", buf);
#else
EXPECT_STREQ("-2147483648", buf);
diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
index 9071acf..bdd6a89 100644
--- a/tests/sys_ptrace_test.cpp
+++ b/tests/sys_ptrace_test.cpp
@@ -183,7 +183,7 @@
run_watchpoint_test_impl<uint8_t>(cpu);
run_watchpoint_test_impl<uint16_t>(cpu);
run_watchpoint_test_impl<uint32_t>(cpu);
-#if __LP64__
+#if defined(__LP64__)
run_watchpoint_test_impl<uint64_t>(cpu);
#endif
}
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index daf6f0b..535eef8 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -80,6 +80,7 @@
command.push_back("-Wall");
command.push_back("-Wextra");
command.push_back("-Werror");
+ command.push_back("-Wundef");
command.push_back("-Wno-unused-macros");
command.push_back("-Wno-unused-function");
command.push_back("-Wno-unused-variable");