Merge "Accuracy tests for libm"
diff --git a/libc/Android.mk b/libc/Android.mk
index 6297f82..f0ee09d 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -609,7 +609,9 @@
-I$(LOCAL_PATH)/dns/include \
-I$(LOCAL_PATH)/private \
-I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
- -include upstream-netbsd/android/include/netbsd-compat.h
+ -include upstream-netbsd/android/include/netbsd-compat.h \
+# -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -636,7 +638,9 @@
-Wno-sign-compare -Wno-uninitialized \
-I$(LOCAL_PATH)/upstream-freebsd/android/include \
-I$(LOCAL_PATH)/upstream-freebsd/lib/libc/include \
- -include freebsd-compat.h
+ -include freebsd-compat.h \
+# -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -661,10 +665,12 @@
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized \
+ -Werror \
-DPOSIX_MISTAKE \
-I$(LOCAL_PATH)/upstream-netbsd/android/include \
-I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
- -include netbsd-compat.h
+ -include netbsd-compat.h \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -689,10 +695,12 @@
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized \
+ -Werror \
-I$(LOCAL_PATH)/upstream-openbsd/android/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/gdtoa/ \
- -include openbsd-compat.h
+ -include openbsd-compat.h \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -718,6 +726,7 @@
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized \
+ -Werror \
-fvisibility=hidden \
-I$(LOCAL_PATH)/upstream-openbsd/android/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
@@ -832,7 +841,9 @@
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags) \
- -DLIBC_STATIC
+ -DLIBC_STATIC \
+ -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
@@ -859,7 +870,9 @@
bionic/libc_init_static.cpp \
LOCAL_CFLAGS := $(libc_common_cflags) \
- -DLIBC_STATIC
+ -DLIBC_STATIC \
+ -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -878,7 +891,7 @@
# ========================================================
include $(CLEAR_VARS)
-LOCAL_CFLAGS := $(libc_common_cflags)
+LOCAL_CFLAGS := $(libc_common_cflags) -Werror
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -942,7 +955,9 @@
LOCAL_CFLAGS := \
$(libc_common_cflags) \
- -DMALLOC_LEAK_CHECK
+ -DMALLOC_LEAK_CHECK \
+ -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
@@ -976,7 +991,9 @@
LOCAL_CFLAGS := \
$(libc_common_cflags) \
- -DMALLOC_QEMU_INSTRUMENT
+ -DMALLOC_QEMU_INSTRUMENT \
+ -Werror \
+
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 83feb65..4a21582 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -228,7 +228,7 @@
int __rt_sigprocmask:rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t) all
int __rt_sigsuspend:rt_sigsuspend(const sigset_t*, size_t) all
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, struct siginfo_t*, struct timespec_t*, size_t) all
-int signalfd4(int, const sigset_t*, size_t, int) all
+int __signalfd4:signalfd4(int, const sigset_t*, size_t, int) all
# sockets
int socket(int, int, int) arm,arm64,mips,mips64,x86_64
diff --git a/libc/arch-arm/bionic/_exit_with_stack_teardown.S b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
index 6fa950e..1a67fed 100644
--- a/libc/arch-arm/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
@@ -29,7 +29,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
ldr r7, =__NR_munmap
swi #0
// If munmap failed, we ignore the failure and exit anyway.
diff --git a/libc/arch-arm/syscalls/signalfd4.S b/libc/arch-arm/syscalls/__signalfd4.S
similarity index 87%
rename from libc/arch-arm/syscalls/signalfd4.S
rename to libc/arch-arm/syscalls/__signalfd4.S
index f8d8a28..712f975 100644
--- a/libc/arch-arm/syscalls/signalfd4.S
+++ b/libc/arch-arm/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
mov ip, r7
ldr r7, =__NR_signalfd4
swi #0
@@ -11,4 +11,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(signalfd4)
+END(__signalfd4)
diff --git a/libc/arch-arm64/bionic/_exit_with_stack_teardown.S b/libc/arch-arm64/bionic/_exit_with_stack_teardown.S
index 075e388..6a7b1e5 100644
--- a/libc/arch-arm64/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-arm64/bionic/_exit_with_stack_teardown.S
@@ -29,7 +29,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
mov w8, __NR_munmap
svc #0
// If munmap failed, we ignore the failure and exit anyway.
diff --git a/libc/arch-arm64/bionic/futex_arm64.S b/libc/arch-arm64/bionic/futex_arm64.S
index d452771..5a47826 100644
--- a/libc/arch-arm64/bionic/futex_arm64.S
+++ b/libc/arch-arm64/bionic/futex_arm64.S
@@ -51,7 +51,7 @@
END(__futex_syscall3)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
-ENTRY(__futex_wait)
+ENTRY_PRIVATE(__futex_wait)
stp x29, x30, [sp, #-16]!
mov x29, sp
@@ -69,7 +69,7 @@
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
-ENTRY(__futex_wake)
+ENTRY_PRIVATE(__futex_wake)
stp x29, x30, [sp, #-16]!
mov x29, sp
diff --git a/libc/arch-arm64/syscalls/signalfd4.S b/libc/arch-arm64/syscalls/__signalfd4.S
similarity index 86%
rename from libc/arch-arm64/syscalls/signalfd4.S
rename to libc/arch-arm64/syscalls/__signalfd4.S
index 7a8f7f7..91510f6 100644
--- a/libc/arch-arm64/syscalls/signalfd4.S
+++ b/libc/arch-arm64/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
@@ -18,4 +18,5 @@
b.hi __set_errno
ret
-END(signalfd4)
+END(__signalfd4)
+.hidden __signalfd4
diff --git a/libc/arch-mips/bionic/_exit_with_stack_teardown.S b/libc/arch-mips/bionic/_exit_with_stack_teardown.S
index 129e3f9..7d47160 100644
--- a/libc/arch-mips/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-mips/bionic/_exit_with_stack_teardown.S
@@ -29,7 +29,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
li v0, __NR_munmap
syscall
// If munmap failed, we ignore the failure and exit anyway.
diff --git a/libc/arch-mips/syscalls/signalfd4.S b/libc/arch-mips/syscalls/__signalfd4.S
similarity index 87%
rename from libc/arch-mips/syscalls/signalfd4.S
rename to libc/arch-mips/syscalls/__signalfd4.S
index e2c2a30..cc9b212 100644
--- a/libc/arch-mips/syscalls/signalfd4.S
+++ b/libc/arch-mips/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
.set noreorder
.cpload t9
li v0, __NR_signalfd4
@@ -16,4 +16,4 @@
j t9
nop
.set reorder
-END(signalfd4)
+END(__signalfd4)
diff --git a/libc/arch-mips64/bionic/_exit_with_stack_teardown.S b/libc/arch-mips64/bionic/_exit_with_stack_teardown.S
index 3b537eb..fcf8cc1 100644
--- a/libc/arch-mips64/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-mips64/bionic/_exit_with_stack_teardown.S
@@ -29,7 +29,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
li v0, __NR_munmap
syscall
// If munmap failed, we ignore the failure and exit anyway.
diff --git a/libc/arch-mips64/syscalls/signalfd4.S b/libc/arch-mips64/syscalls/__signalfd4.S
similarity index 86%
rename from libc/arch-mips64/syscalls/signalfd4.S
rename to libc/arch-mips64/syscalls/__signalfd4.S
index 594c73d..c4fe77b 100644
--- a/libc/arch-mips64/syscalls/signalfd4.S
+++ b/libc/arch-mips64/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
.set push
.set noreorder
li v0, __NR_signalfd4
@@ -22,4 +22,5 @@
j t9
move ra, t0
.set pop
-END(signalfd4)
+END(__signalfd4)
+.hidden __signalfd4
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
index e94ae90..ce8c2ea 100644
--- a/libc/arch-x86/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
@@ -1,7 +1,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
// We can trash registers because this function never returns.
mov 4(%esp), %ebx // stackBase
mov 8(%esp), %ecx // stackSize
diff --git a/libc/arch-x86/syscalls/signalfd4.S b/libc/arch-x86/syscalls/__signalfd4.S
similarity index 94%
rename from libc/arch-x86/syscalls/signalfd4.S
rename to libc/arch-x86/syscalls/__signalfd4.S
index 1fe6c68..7cbe474 100644
--- a/libc/arch-x86/syscalls/signalfd4.S
+++ b/libc/arch-x86/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
pushl %ebx
pushl %ecx
pushl %edx
@@ -31,4 +31,4 @@
popl %ecx
popl %ebx
ret
-END(signalfd4)
+END(__signalfd4)
diff --git a/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S b/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
index f7bc962..d1f53af 100644
--- a/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
@@ -29,7 +29,7 @@
#include <private/bionic_asm.h>
// void _exit_with_stack_teardown(void* stackBase, size_t stackSize)
-ENTRY(_exit_with_stack_teardown)
+ENTRY_PRIVATE(_exit_with_stack_teardown)
mov $__NR_munmap, %eax
syscall
// If munmap failed, we ignore the failure and exit anyway.
diff --git a/libc/arch-x86_64/bionic/futex_x86_64.S b/libc/arch-x86_64/bionic/futex_x86_64.S
index f85d583..25cdf1b 100644
--- a/libc/arch-x86_64/bionic/futex_x86_64.S
+++ b/libc/arch-x86_64/bionic/futex_x86_64.S
@@ -32,7 +32,7 @@
#define FUTEX_WAKE 1
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
-ENTRY(__futex_wait)
+ENTRY_PRIVATE(__futex_wait)
mov %rdx, %r10 /* timeout */
mov %esi, %edx /* val */
mov $FUTEX_WAIT, %esi /* op */
@@ -42,7 +42,7 @@
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
-ENTRY(__futex_wake)
+ENTRY_PRIVATE(__futex_wake)
mov %esi, %edx
mov $FUTEX_WAKE, %esi
mov $__NR_futex, %eax
diff --git a/libc/arch-x86_64/syscalls/signalfd4.S b/libc/arch-x86_64/syscalls/__signalfd4.S
similarity index 84%
rename from libc/arch-x86_64/syscalls/signalfd4.S
rename to libc/arch-x86_64/syscalls/__signalfd4.S
index 4d8a1b6..fafe371 100644
--- a/libc/arch-x86_64/syscalls/signalfd4.S
+++ b/libc/arch-x86_64/syscalls/__signalfd4.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(signalfd4)
+ENTRY(__signalfd4)
movq %rcx, %r10
movl $__NR_signalfd4, %eax
syscall
@@ -14,4 +14,5 @@
orq $-1, %rax
1:
ret
-END(signalfd4)
+END(__signalfd4)
+.hidden __signalfd4
diff --git a/libc/bionic/arc4random.c b/libc/bionic/arc4random.c
index eac4b0c..687030b 100644
--- a/libc/bionic/arc4random.c
+++ b/libc/bionic/arc4random.c
@@ -171,19 +171,6 @@
return (rs.s[(si + sj) & 0xff]);
}
-u_int8_t
-__arc4_getbyte(void)
-{
- u_int8_t val;
-
- _ARC4_LOCK();
- if (--arc4_count == 0 || !rs_initialized)
- arc4_stir();
- val = arc4_getbyte();
- _ARC4_UNLOCK();
- return val;
-}
-
static inline u_int32_t
arc4_getword(void)
{
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index 356ecb1..8ae0bb5 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -54,8 +54,8 @@
*/
int gMallocLeakZygoteChild = 0;
-pthread_mutex_t g_allocations_mutex = PTHREAD_MUTEX_INITIALIZER;
-HashTable g_hash_table;
+__LIBC_HIDDEN__ pthread_mutex_t g_allocations_mutex = PTHREAD_MUTEX_INITIALIZER;
+__LIBC_HIDDEN__ HashTable g_hash_table;
// =============================================================================
// output functions
@@ -113,6 +113,8 @@
* not include heap overhead
* "*backtraceSize" is set to the maximum number of entries in the back trace
*/
+
+// Exported for use by ddms.
extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
size_t* infoSize, size_t* totalMemory, size_t* backtraceSize) {
// don't do anything if we have invalid arguments
@@ -182,6 +184,7 @@
dlfree(list);
}
+// Exported for use by ddms.
extern "C" void free_malloc_leak_info(uint8_t* info) {
dlfree(info);
}
@@ -286,11 +289,11 @@
* backlog we use to detect multiple frees. If the property is not set, the
* backlog length defaults to BACKLOG_DEFAULT_LEN.
*/
-unsigned int g_malloc_debug_backlog;
+__LIBC_HIDDEN__ unsigned int g_malloc_debug_backlog;
#define BACKLOG_DEFAULT_LEN 100
/* The value of libc.debug.malloc. */
-int g_malloc_debug_level;
+__LIBC_HIDDEN__ int g_malloc_debug_level;
template<typename FunctionType>
static void InitMallocFunction(void* malloc_impl_handler, FunctionType* func, const char* prefix, const char* suffix) {
diff --git a/libc/bionic/signalfd.cpp b/libc/bionic/signalfd.cpp
index 36ef81d..63e1db4 100644
--- a/libc/bionic/signalfd.cpp
+++ b/libc/bionic/signalfd.cpp
@@ -30,9 +30,9 @@
#include "private/kernel_sigset_t.h"
-extern "C" int signalfd4(int fd, kernel_sigset_t* mask, size_t sizemask, int flags);
+extern "C" int __signalfd4(int fd, kernel_sigset_t* mask, size_t sizemask, int flags);
int signalfd(int fd, const sigset_t* mask, int flags) {
kernel_sigset_t in_set(mask);
- return signalfd4(fd, &in_set, sizeof(in_set), flags);
+ return __signalfd4(fd, &in_set, sizeof(in_set), flags);
}
diff --git a/libc/private/bionic_futex.h b/libc/private/bionic_futex.h
index bfc3520..d01b859 100644
--- a/libc/private/bionic_futex.h
+++ b/libc/private/bionic_futex.h
@@ -39,23 +39,11 @@
extern int __futex_syscall3(volatile void *ftx, int op, int val);
extern int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
-#ifndef FUTEX_PRIVATE_FLAG
-#define FUTEX_PRIVATE_FLAG 128
-#endif
-
-#ifndef FUTEX_WAIT_PRIVATE
-#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT|FUTEX_PRIVATE_FLAG)
-#endif
-
-#ifndef FUTEX_WAKE_PRIVATE
-#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE|FUTEX_PRIVATE_FLAG)
-#endif
-
/* Like __futex_wait/wake, but take an additional 'pshared' argument.
* when non-0, this will use normal futexes. Otherwise, private futexes.
*/
-extern int __futex_wake_ex(volatile void *ftx, int pshared, int val);
-extern int __futex_wait_ex(volatile void *ftx, int pshared, int val, const struct timespec *timeout);
+__LIBC_HIDDEN__ int __futex_wake_ex(volatile void* ftx, int pshared, int val);
+__LIBC_HIDDEN__ int __futex_wait_ex(volatile void* ftx, int pshared, int val, const struct timespec* timeout);
__END_DECLS
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 907fd21..7afa761 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -63,10 +63,7 @@
int __vfwprintf(FILE * __restrict, const wchar_t * __restrict, __va_list);
int __vfwscanf(FILE * __restrict, const wchar_t * __restrict, __va_list);
-/*
- * Function to clean up streams, called from abort() and exit().
- */
-extern void (*__cleanup)(void);
+extern void __atexit_register_cleanup(void (*)(void));
extern int __sdidinit;
/*
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index 521a599..9ebb09b 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -121,10 +121,6 @@
const char* signal_name = "???";
bool has_address = false;
switch (signum) {
- case SIGILL:
- signal_name = "SIGILL";
- has_address = true;
- break;
case SIGABRT:
signal_name = "SIGABRT";
break;
@@ -136,6 +132,13 @@
signal_name = "SIGFPE";
has_address = true;
break;
+ case SIGILL:
+ signal_name = "SIGILL";
+ has_address = true;
+ break;
+ case SIGPIPE:
+ signal_name = "SIGPIPE";
+ break;
case SIGSEGV:
signal_name = "SIGSEGV";
has_address = true;
@@ -145,8 +148,8 @@
signal_name = "SIGSTKFLT";
break;
#endif
- case SIGPIPE:
- signal_name = "SIGPIPE";
+ case SIGTRAP:
+ signal_name = "SIGTRAP";
break;
}
@@ -266,6 +269,7 @@
#if defined(SIGSTKFLT)
case SIGSTKFLT:
#endif
+ case SIGTRAP:
tgkill(getpid(), gettid(), signal_number);
break;
default: // SIGILL, SIGBUS, SIGSEGV