diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-05-29 06:54:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-29 06:55:00 +0000 |
commit | d9886ee33bff5823d6f620a1c73fb7d335246b89 (patch) | |
tree | 85f2dbae997e523fe65b9806562fe566ccb6568f | |
parent | f7368f5fcd79f647aa16b98214cb1ef30f475452 (diff) | |
parent | 244dca2ed2a3f87b0f93d23f1bc2ea0ba9c8d783 (diff) | |
download | prebuilts_ndk-d9886ee33bff5823d6f620a1c73fb7d335246b89.zip prebuilts_ndk-d9886ee33bff5823d6f620a1c73fb7d335246b89.tar.gz prebuilts_ndk-d9886ee33bff5823d6f620a1c73fb7d335246b89.tar.bz2 |
Merge "Refresh 64-bit headers/libs (WW21)"
54 files changed, 1461 insertions, 90 deletions
diff --git a/9/platforms/android-19/arch-arm64/usr/include/dlfcn.h b/9/platforms/android-19/arch-arm64/usr/include/dlfcn.h index 7daa8f7..8dde08c 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/dlfcn.h +++ b/9/platforms/android-19/arch-arm64/usr/include/dlfcn.h @@ -50,15 +50,29 @@ extern void* dlsym(void* handle, const char* symbol); extern int dladdr(const void* addr, Dl_info *info); enum { +#if defined(__LP64__) + RTLD_NOW = 2, +#else RTLD_NOW = 0, +#endif RTLD_LAZY = 1, RTLD_LOCAL = 0, +#if defined(__LP64__) + RTLD_GLOBAL = 0x00100, +#else RTLD_GLOBAL = 2, +#endif + RTLD_NOLOAD = 4, }; +#if defined (__LP64__) +#define RTLD_DEFAULT ((void*) 0) +#define RTLD_NEXT ((void*) -1L) +#else #define RTLD_DEFAULT ((void*) 0xffffffff) #define RTLD_NEXT ((void*) 0xfffffffe) +#endif __END_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/fenv.h b/9/platforms/android-19/arch-arm64/usr/include/fenv.h index 6966e0d..73ecc80 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/fenv.h +++ b/9/platforms/android-19/arch-arm64/usr/include/fenv.h @@ -34,6 +34,7 @@ #include <machine/fenv.h> __BEGIN_DECLS +#pragma GCC visibility push(default) int feclearexcept(int); int fegetexceptflag(fexcept_t *, int); @@ -64,6 +65,7 @@ int fegetexcept(void); extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) +#pragma GCC visibility pop __END_DECLS #endif /* ! _FENV_H_ */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/math.h b/9/platforms/android-19/arch-arm64/usr/include/math.h index c264583..4faec33 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/math.h +++ b/9/platforms/android-19/arch-arm64/usr/include/math.h @@ -20,6 +20,9 @@ #include <sys/cdefs.h> #include <limits.h> +__BEGIN_DECLS +#pragma GCC visibility push(default) + /* * ANSI/POSIX */ @@ -165,7 +168,7 @@ extern int signgam; * effect of raising floating-point exceptions, so they are not declared * as __pure2. In C99, FENV_ACCESS affects the purity of these functions. */ -__BEGIN_DECLS + /* * ANSI/POSIX */ @@ -282,6 +285,7 @@ double trunc(double); double drem(double, double); int finite(double) __pure2; int isnanf(float) __pure2; +long double significandl(long double); /* * Reentrant version of gamma & lgamma; passes signgam back by reference @@ -464,6 +468,7 @@ void sincosf(float, float*, float*); void sincosl(long double, long double*, long double*); #endif /* _GNU_SOURCE */ +#pragma GCC visibility pop __END_DECLS #endif /* !_MATH_H_ */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/pthread.h b/9/platforms/android-19/arch-arm64/usr/include/pthread.h index 49f943a..5c9b626 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/pthread.h +++ b/9/platforms/android-19/arch-arm64/usr/include/pthread.h @@ -94,16 +94,28 @@ typedef long pthread_condattr_t; typedef long pthread_rwlockattr_t; typedef struct { - pthread_mutex_t lock; - pthread_cond_t cond; - int numLocks; - int writerThreadId; - int pendingReaders; - int pendingWriters; - void* __reserved[4]; +#if !defined(__LP64__) + pthread_mutex_t __unused_lock; + pthread_cond_t __unused_cond; +#endif + volatile int32_t state; // 0=unlock, -1=writer lock, +n=reader lock + volatile int32_t writer_thread_id; + volatile int32_t pending_readers; + volatile int32_t pending_writers; + int32_t attr; +#ifdef __LP64__ + char __reserved[36]; +#else + char __reserved[12]; +#endif + } pthread_rwlock_t; -#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, { NULL, NULL, NULL, NULL } } +#ifdef __LP64__ + #define PTHREAD_RWLOCK_INITIALIZER { 0, 0, 0, 0, 0, { 0 } } +#else + #define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { 0 } } +#endif typedef int pthread_key_t; typedef long pthread_t; diff --git a/9/platforms/android-19/arch-arm64/usr/include/stdatomic.h b/9/platforms/android-19/arch-arm64/usr/include/stdatomic.h new file mode 100644 index 0000000..43ec753 --- /dev/null +++ b/9/platforms/android-19/arch-arm64/usr/include/stdatomic.h @@ -0,0 +1,420 @@ +/*- + * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> + * David Chisnall <theraven@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _STDATOMIC_H_ +#define _STDATOMIC_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <stdbool.h> + +#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#define __CLANG_ATOMICS +#elif __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif defined(__GNUC__) +#define __SYNC_ATOMICS +#else +#error "stdatomic.h does not support your compiler" +#endif + +/* + * 7.17.1 Atomic lock-free macros. + */ + +#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/* + * 7.17.2 Initialization. + */ + +#if defined(__CLANG_ATOMICS) +#define ATOMIC_VAR_INIT(value) (value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#else +#define ATOMIC_VAR_INIT(value) { .__val = (value) } +#define atomic_init(obj, value) ((void)((obj)->__val = (value))) +#endif + +/* + * Clang and recent GCC both provide predefined macros for the memory + * orderings. If we are using a compiler that doesn't define them, use the + * clang values - these will be ignored in the fallback path. + */ + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +/* + * 7.17.3 Order and consistency. + * + * The memory_order_* constants that denote the barrier behaviour of the + * atomic operations. + */ + +typedef enum { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +/* + * 7.17.4 Fences. + */ + +static __inline void +atomic_thread_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_thread_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_thread_fence(__order); +#else + __sync_synchronize(); +#endif +} + +static __inline void +atomic_signal_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_signal_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_signal_fence(__order); +#else + __asm volatile ("" ::: "memory"); +#endif +} + +/* + * 7.17.5 Lock-free property. + */ + +#if defined(_KERNEL) +/* Atomics in kernelspace are always lock-free. */ +#define atomic_is_lock_free(obj) \ + ((void)(obj), (_Bool)1) +#elif defined(__CLANG_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof(*(obj)), obj) +#elif defined(__GNUC_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) +#else +#define atomic_is_lock_free(obj) \ + ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) +#endif + +/* + * 7.17.6 Atomic integer types. + */ + +#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) +/* + * No native support for _Atomic(). Place object in structure to prevent + * most forms of direct non-atomic access. + */ +#define _Atomic(T) struct { T volatile __val; } +#endif + +typedef _Atomic(bool) atomic_bool; +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +typedef _Atomic(char16_t) atomic_char16_t; +typedef _Atomic(char32_t) atomic_char32_t; +typedef _Atomic(wchar_t) atomic_wchar_t; +typedef _Atomic(int_least8_t) atomic_int_least8_t; +typedef _Atomic(uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(int_least16_t) atomic_int_least16_t; +typedef _Atomic(uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(int_least32_t) atomic_int_least32_t; +typedef _Atomic(uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(int_least64_t) atomic_int_least64_t; +typedef _Atomic(uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(intptr_t) atomic_intptr_t; +typedef _Atomic(uintptr_t) atomic_uintptr_t; +typedef _Atomic(size_t) atomic_size_t; +typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(intmax_t) atomic_intmax_t; +typedef _Atomic(uintmax_t) atomic_uintmax_t; + +/* + * 7.17.7 Operations on atomic types. + */ + +/* + * Compiler-specific operations. + */ + +#if defined(__CLANG_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ + success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ + success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __c11_atomic_exchange(object, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __c11_atomic_fetch_add(object, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __c11_atomic_fetch_and(object, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __c11_atomic_fetch_or(object, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __c11_atomic_fetch_sub(object, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __c11_atomic_fetch_xor(object, operand, order) +#define atomic_load_explicit(object, order) \ + __c11_atomic_load(object, order) +#define atomic_store_explicit(object, desired, order) \ + __c11_atomic_store(object, desired, order) +#elif defined(__GNUC_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 0, success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 1, success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __atomic_exchange_n(&(object)->__val, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __atomic_fetch_add(&(object)->__val, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __atomic_fetch_and(&(object)->__val, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __atomic_fetch_or(&(object)->__val, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __atomic_fetch_sub(&(object)->__val, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __atomic_fetch_xor(&(object)->__val, operand, order) +#define atomic_load_explicit(object, order) \ + __atomic_load_n(&(object)->__val, order) +#define atomic_store_explicit(object, desired, order) \ + __atomic_store_n(&(object)->__val, desired, order) +#else +#define __atomic_apply_stride(object, operand) \ + (((__typeof__((object)->__val))0) + (operand)) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) __extension__ ({ \ + __typeof__(expected) __ep = (expected); \ + __typeof__(*__ep) __e = *__ep; \ + (void)(success); (void)(failure); \ + (bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ + __e, desired)) == __e); \ +}) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) +#if __has_builtin(__sync_swap) +/* Clang provides a full-barrier atomic exchange - use it if available. */ +#define atomic_exchange_explicit(object, desired, order) \ + ((void)(order), __sync_swap(&(object)->__val, desired)) +#else +/* + * __sync_lock_test_and_set() is only an acquire barrier in theory (although in + * practice it is usually a full barrier) so we need an explicit barrier before + * it. + */ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o = (object); \ + __typeof__(desired) __d = (desired); \ + (void)(order); \ + __sync_synchronize(); \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ +}) +#endif +#define atomic_fetch_add_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_and_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) +#define atomic_fetch_or_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) +#define atomic_fetch_sub_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_xor_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) +#define atomic_load_explicit(object, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) +#define atomic_store_explicit(object, desired, order) \ + ((void)atomic_exchange_explicit(object, desired, order)) +#endif + +/* + * Convenience functions. + * + * Don't provide these in kernel space. In kernel space, we should be + * disciplined enough to always provide explicit barriers. + */ + +#ifndef _KERNEL +#define atomic_compare_exchange_strong(object, expected, desired) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_weak_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_exchange(object, desired) \ + atomic_exchange_explicit(object, desired, memory_order_seq_cst) +#define atomic_fetch_add(object, operand) \ + atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_and(object, operand) \ + atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_or(object, operand) \ + atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_sub(object, operand) \ + atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_xor(object, operand) \ + atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) +#define atomic_load(object) \ + atomic_load_explicit(object, memory_order_seq_cst) +#define atomic_store(object, desired) \ + atomic_store_explicit(object, desired, memory_order_seq_cst) +#endif /* !_KERNEL */ + +/* + * 7.17.8 Atomic flag type and operations. + * + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some + * kind of compiler built-in type we could use? + */ + +typedef struct { + atomic_bool __flag; +} atomic_flag; + +#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } + +static __inline bool +atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, + memory_order __order) +{ + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); +} + +static __inline void +atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) +{ + + atomic_store_explicit(&__object->__flag, 0, __order); +} + +#ifndef _KERNEL +static __inline bool +atomic_flag_test_and_set(volatile atomic_flag *__object) +{ + + return (atomic_flag_test_and_set_explicit(__object, + memory_order_seq_cst)); +} + +static __inline void +atomic_flag_clear(volatile atomic_flag *__object) +{ + + atomic_flag_clear_explicit(__object, memory_order_seq_cst); +} +#endif /* !_KERNEL */ + +#endif /* !_STDATOMIC_H_ */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/stdio.h b/9/platforms/android-19/arch-arm64/usr/include/stdio.h index 1d89b9b..b026843 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/stdio.h +++ b/9/platforms/android-19/arch-arm64/usr/include/stdio.h @@ -250,6 +250,9 @@ int vfprintf(FILE * __restrict, const char * __restrict, __va_list) int vprintf(const char * __restrict, __va_list) __printflike(1, 0); +int dprintf(int, const char * __restrict, ...) __printflike(2, 3); +int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); + #ifndef __AUDIT__ char* gets(char*) __warnattr("gets is very unsafe; consider using fgets"); int sprintf(char* __restrict, const char* __restrict, ...) @@ -359,21 +362,6 @@ __END_DECLS #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) #endif /* __BSD_VISIBLE */ -#ifdef _GNU_SOURCE -/* - * glibc defines dprintf(int, const char*, ...), which is poorly named - * and likely to conflict with locally defined debugging printfs - * fdprintf is a better name, and some programs that use fdprintf use a - * #define fdprintf dprintf for compatibility - */ -__BEGIN_DECLS -int fdprintf(int, const char*, ...) - __printflike(2, 3); -int vfdprintf(int, const char*, __va_list) - __printflike(2, 0); -__END_DECLS -#endif /* _GNU_SOURCE */ - #if defined(__BIONIC_FORTIFY) __BEGIN_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/cdefs.h b/9/platforms/android-19/arch-arm64/usr/include/sys/cdefs.h index 8ab5b47..37c43cf 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/cdefs.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/cdefs.h @@ -38,6 +38,24 @@ #define _SYS_CDEFS_H_ /* + * Testing against Clang-specific extensions. + */ + +#ifndef __has_extension +#define __has_extension __has_feature +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + + +/* * Macro to test if we're using a GNU C compiler of a specific vintage * or later, for e.g. features that appeared in a particular version * of GNU C. Usage: diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/ucontext.h b/9/platforms/android-19/arch-arm64/usr/include/sys/ucontext.h index f150ac7..d6c6b43 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/ucontext.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/ucontext.h @@ -60,8 +60,6 @@ enum { typedef int greg_t; typedef greg_t gregset_t[NGREG]; -/* TODO: fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -71,13 +69,12 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; - /* TODO: uc_regspace */ + char __padding[128 - sizeof(sigset_t)]; + unsigned long uc_regspace[128] __attribute__((__aligned__(8))); } ucontext_t; #elif defined(__aarch64__) -/* TODO: gregset_t and fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -201,6 +198,7 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; + char __padding[128 - sizeof(sigset_t)]; } ucontext_t; #elif defined(__mips64__) diff --git a/9/platforms/android-19/arch-arm64/usr/include/unistd.h b/9/platforms/android-19/arch-arm64/usr/include/unistd.h index 6cb36d8..08a82e6 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/unistd.h +++ b/9/platforms/android-19/arch-arm64/usr/include/unistd.h @@ -207,7 +207,7 @@ extern int setdomainname(const char *, size_t); /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ + __typeof__(exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libc.a b/9/platforms/android-19/arch-arm64/usr/lib/libc.a Binary files differindex ea9ec46..e4e90ce 100644 --- a/9/platforms/android-19/arch-arm64/usr/lib/libc.a +++ b/9/platforms/android-19/arch-arm64/usr/lib/libc.a diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libc.so b/9/platforms/android-19/arch-arm64/usr/lib/libc.so Binary files differindex e253ddc..4354221 100755 --- a/9/platforms/android-19/arch-arm64/usr/lib/libc.so +++ b/9/platforms/android-19/arch-arm64/usr/lib/libc.so diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libdl.so b/9/platforms/android-19/arch-arm64/usr/lib/libdl.so Binary files differindex 3815a23..ccc705c 100755 --- a/9/platforms/android-19/arch-arm64/usr/lib/libdl.so +++ b/9/platforms/android-19/arch-arm64/usr/lib/libdl.so diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libm.a b/9/platforms/android-19/arch-arm64/usr/lib/libm.a Binary files differindex 5e95ceb..69f5a00 100644 --- a/9/platforms/android-19/arch-arm64/usr/lib/libm.a +++ b/9/platforms/android-19/arch-arm64/usr/lib/libm.a diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libm.so b/9/platforms/android-19/arch-arm64/usr/lib/libm.so Binary files differindex 454ce52..b783733 100755 --- a/9/platforms/android-19/arch-arm64/usr/lib/libm.so +++ b/9/platforms/android-19/arch-arm64/usr/lib/libm.so diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.a b/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.a Binary files differindex 25d4657..e556cfd 100644 --- a/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.a +++ b/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.a diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.so b/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.so Binary files differindex 2b7cf91..0427aa3 100755 --- a/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.so +++ b/9/platforms/android-19/arch-arm64/usr/lib/libstdc++.so diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libz.a b/9/platforms/android-19/arch-arm64/usr/lib/libz.a Binary files differindex b41e0fb..d8cc6a4 100644 --- a/9/platforms/android-19/arch-arm64/usr/lib/libz.a +++ b/9/platforms/android-19/arch-arm64/usr/lib/libz.a diff --git a/9/platforms/android-19/arch-arm64/usr/lib/libz.so b/9/platforms/android-19/arch-arm64/usr/lib/libz.so Binary files differnew file mode 100755 index 0000000..759ba76 --- /dev/null +++ b/9/platforms/android-19/arch-arm64/usr/lib/libz.so diff --git a/9/platforms/android-19/arch-mips64/usr/include/dlfcn.h b/9/platforms/android-19/arch-mips64/usr/include/dlfcn.h index 7daa8f7..8dde08c 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/dlfcn.h +++ b/9/platforms/android-19/arch-mips64/usr/include/dlfcn.h @@ -50,15 +50,29 @@ extern void* dlsym(void* handle, const char* symbol); extern int dladdr(const void* addr, Dl_info *info); enum { +#if defined(__LP64__) + RTLD_NOW = 2, +#else RTLD_NOW = 0, +#endif RTLD_LAZY = 1, RTLD_LOCAL = 0, +#if defined(__LP64__) + RTLD_GLOBAL = 0x00100, +#else RTLD_GLOBAL = 2, +#endif + RTLD_NOLOAD = 4, }; +#if defined (__LP64__) +#define RTLD_DEFAULT ((void*) 0) +#define RTLD_NEXT ((void*) -1L) +#else #define RTLD_DEFAULT ((void*) 0xffffffff) #define RTLD_NEXT ((void*) 0xfffffffe) +#endif __END_DECLS diff --git a/9/platforms/android-19/arch-mips64/usr/include/fenv.h b/9/platforms/android-19/arch-mips64/usr/include/fenv.h index 6966e0d..73ecc80 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/fenv.h +++ b/9/platforms/android-19/arch-mips64/usr/include/fenv.h @@ -34,6 +34,7 @@ #include <machine/fenv.h> __BEGIN_DECLS +#pragma GCC visibility push(default) int feclearexcept(int); int fegetexceptflag(fexcept_t *, int); @@ -64,6 +65,7 @@ int fegetexcept(void); extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) +#pragma GCC visibility pop __END_DECLS #endif /* ! _FENV_H_ */ diff --git a/9/platforms/android-19/arch-mips64/usr/include/math.h b/9/platforms/android-19/arch-mips64/usr/include/math.h index c264583..4faec33 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/math.h +++ b/9/platforms/android-19/arch-mips64/usr/include/math.h @@ -20,6 +20,9 @@ #include <sys/cdefs.h> #include <limits.h> +__BEGIN_DECLS +#pragma GCC visibility push(default) + /* * ANSI/POSIX */ @@ -165,7 +168,7 @@ extern int signgam; * effect of raising floating-point exceptions, so they are not declared * as __pure2. In C99, FENV_ACCESS affects the purity of these functions. */ -__BEGIN_DECLS + /* * ANSI/POSIX */ @@ -282,6 +285,7 @@ double trunc(double); double drem(double, double); int finite(double) __pure2; int isnanf(float) __pure2; +long double significandl(long double); /* * Reentrant version of gamma & lgamma; passes signgam back by reference @@ -464,6 +468,7 @@ void sincosf(float, float*, float*); void sincosl(long double, long double*, long double*); #endif /* _GNU_SOURCE */ +#pragma GCC visibility pop __END_DECLS #endif /* !_MATH_H_ */ diff --git a/9/platforms/android-19/arch-mips64/usr/include/pthread.h b/9/platforms/android-19/arch-mips64/usr/include/pthread.h index 49f943a..5c9b626 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/pthread.h +++ b/9/platforms/android-19/arch-mips64/usr/include/pthread.h @@ -94,16 +94,28 @@ typedef long pthread_condattr_t; typedef long pthread_rwlockattr_t; typedef struct { - pthread_mutex_t lock; - pthread_cond_t cond; - int numLocks; - int writerThreadId; - int pendingReaders; - int pendingWriters; - void* __reserved[4]; +#if !defined(__LP64__) + pthread_mutex_t __unused_lock; + pthread_cond_t __unused_cond; +#endif + volatile int32_t state; // 0=unlock, -1=writer lock, +n=reader lock + volatile int32_t writer_thread_id; + volatile int32_t pending_readers; + volatile int32_t pending_writers; + int32_t attr; +#ifdef __LP64__ + char __reserved[36]; +#else + char __reserved[12]; +#endif + } pthread_rwlock_t; -#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, { NULL, NULL, NULL, NULL } } +#ifdef __LP64__ + #define PTHREAD_RWLOCK_INITIALIZER { 0, 0, 0, 0, 0, { 0 } } +#else + #define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { 0 } } +#endif typedef int pthread_key_t; typedef long pthread_t; diff --git a/9/platforms/android-19/arch-mips64/usr/include/stdatomic.h b/9/platforms/android-19/arch-mips64/usr/include/stdatomic.h new file mode 100644 index 0000000..43ec753 --- /dev/null +++ b/9/platforms/android-19/arch-mips64/usr/include/stdatomic.h @@ -0,0 +1,420 @@ +/*- + * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> + * David Chisnall <theraven@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _STDATOMIC_H_ +#define _STDATOMIC_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <stdbool.h> + +#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#define __CLANG_ATOMICS +#elif __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif defined(__GNUC__) +#define __SYNC_ATOMICS +#else +#error "stdatomic.h does not support your compiler" +#endif + +/* + * 7.17.1 Atomic lock-free macros. + */ + +#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/* + * 7.17.2 Initialization. + */ + +#if defined(__CLANG_ATOMICS) +#define ATOMIC_VAR_INIT(value) (value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#else +#define ATOMIC_VAR_INIT(value) { .__val = (value) } +#define atomic_init(obj, value) ((void)((obj)->__val = (value))) +#endif + +/* + * Clang and recent GCC both provide predefined macros for the memory + * orderings. If we are using a compiler that doesn't define them, use the + * clang values - these will be ignored in the fallback path. + */ + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +/* + * 7.17.3 Order and consistency. + * + * The memory_order_* constants that denote the barrier behaviour of the + * atomic operations. + */ + +typedef enum { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +/* + * 7.17.4 Fences. + */ + +static __inline void +atomic_thread_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_thread_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_thread_fence(__order); +#else + __sync_synchronize(); +#endif +} + +static __inline void +atomic_signal_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_signal_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_signal_fence(__order); +#else + __asm volatile ("" ::: "memory"); +#endif +} + +/* + * 7.17.5 Lock-free property. + */ + +#if defined(_KERNEL) +/* Atomics in kernelspace are always lock-free. */ +#define atomic_is_lock_free(obj) \ + ((void)(obj), (_Bool)1) +#elif defined(__CLANG_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof(*(obj)), obj) +#elif defined(__GNUC_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) +#else +#define atomic_is_lock_free(obj) \ + ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) +#endif + +/* + * 7.17.6 Atomic integer types. + */ + +#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) +/* + * No native support for _Atomic(). Place object in structure to prevent + * most forms of direct non-atomic access. + */ +#define _Atomic(T) struct { T volatile __val; } +#endif + +typedef _Atomic(bool) atomic_bool; +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +typedef _Atomic(char16_t) atomic_char16_t; +typedef _Atomic(char32_t) atomic_char32_t; +typedef _Atomic(wchar_t) atomic_wchar_t; +typedef _Atomic(int_least8_t) atomic_int_least8_t; +typedef _Atomic(uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(int_least16_t) atomic_int_least16_t; +typedef _Atomic(uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(int_least32_t) atomic_int_least32_t; +typedef _Atomic(uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(int_least64_t) atomic_int_least64_t; +typedef _Atomic(uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(intptr_t) atomic_intptr_t; +typedef _Atomic(uintptr_t) atomic_uintptr_t; +typedef _Atomic(size_t) atomic_size_t; +typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(intmax_t) atomic_intmax_t; +typedef _Atomic(uintmax_t) atomic_uintmax_t; + +/* + * 7.17.7 Operations on atomic types. + */ + +/* + * Compiler-specific operations. + */ + +#if defined(__CLANG_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ + success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ + success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __c11_atomic_exchange(object, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __c11_atomic_fetch_add(object, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __c11_atomic_fetch_and(object, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __c11_atomic_fetch_or(object, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __c11_atomic_fetch_sub(object, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __c11_atomic_fetch_xor(object, operand, order) +#define atomic_load_explicit(object, order) \ + __c11_atomic_load(object, order) +#define atomic_store_explicit(object, desired, order) \ + __c11_atomic_store(object, desired, order) +#elif defined(__GNUC_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 0, success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 1, success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __atomic_exchange_n(&(object)->__val, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __atomic_fetch_add(&(object)->__val, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __atomic_fetch_and(&(object)->__val, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __atomic_fetch_or(&(object)->__val, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __atomic_fetch_sub(&(object)->__val, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __atomic_fetch_xor(&(object)->__val, operand, order) +#define atomic_load_explicit(object, order) \ + __atomic_load_n(&(object)->__val, order) +#define atomic_store_explicit(object, desired, order) \ + __atomic_store_n(&(object)->__val, desired, order) +#else +#define __atomic_apply_stride(object, operand) \ + (((__typeof__((object)->__val))0) + (operand)) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) __extension__ ({ \ + __typeof__(expected) __ep = (expected); \ + __typeof__(*__ep) __e = *__ep; \ + (void)(success); (void)(failure); \ + (bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ + __e, desired)) == __e); \ +}) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) +#if __has_builtin(__sync_swap) +/* Clang provides a full-barrier atomic exchange - use it if available. */ +#define atomic_exchange_explicit(object, desired, order) \ + ((void)(order), __sync_swap(&(object)->__val, desired)) +#else +/* + * __sync_lock_test_and_set() is only an acquire barrier in theory (although in + * practice it is usually a full barrier) so we need an explicit barrier before + * it. + */ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o = (object); \ + __typeof__(desired) __d = (desired); \ + (void)(order); \ + __sync_synchronize(); \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ +}) +#endif +#define atomic_fetch_add_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_and_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) +#define atomic_fetch_or_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) +#define atomic_fetch_sub_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_xor_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) +#define atomic_load_explicit(object, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) +#define atomic_store_explicit(object, desired, order) \ + ((void)atomic_exchange_explicit(object, desired, order)) +#endif + +/* + * Convenience functions. + * + * Don't provide these in kernel space. In kernel space, we should be + * disciplined enough to always provide explicit barriers. + */ + +#ifndef _KERNEL +#define atomic_compare_exchange_strong(object, expected, desired) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_weak_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_exchange(object, desired) \ + atomic_exchange_explicit(object, desired, memory_order_seq_cst) +#define atomic_fetch_add(object, operand) \ + atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_and(object, operand) \ + atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_or(object, operand) \ + atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_sub(object, operand) \ + atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_xor(object, operand) \ + atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) +#define atomic_load(object) \ + atomic_load_explicit(object, memory_order_seq_cst) +#define atomic_store(object, desired) \ + atomic_store_explicit(object, desired, memory_order_seq_cst) +#endif /* !_KERNEL */ + +/* + * 7.17.8 Atomic flag type and operations. + * + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some + * kind of compiler built-in type we could use? + */ + +typedef struct { + atomic_bool __flag; +} atomic_flag; + +#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } + +static __inline bool +atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, + memory_order __order) +{ + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); +} + +static __inline void +atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) +{ + + atomic_store_explicit(&__object->__flag, 0, __order); +} + +#ifndef _KERNEL +static __inline bool +atomic_flag_test_and_set(volatile atomic_flag *__object) +{ + + return (atomic_flag_test_and_set_explicit(__object, + memory_order_seq_cst)); +} + +static __inline void +atomic_flag_clear(volatile atomic_flag *__object) +{ + + atomic_flag_clear_explicit(__object, memory_order_seq_cst); +} +#endif /* !_KERNEL */ + +#endif /* !_STDATOMIC_H_ */ diff --git a/9/platforms/android-19/arch-mips64/usr/include/stdio.h b/9/platforms/android-19/arch-mips64/usr/include/stdio.h index 1d89b9b..b026843 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/stdio.h +++ b/9/platforms/android-19/arch-mips64/usr/include/stdio.h @@ -250,6 +250,9 @@ int vfprintf(FILE * __restrict, const char * __restrict, __va_list) int vprintf(const char * __restrict, __va_list) __printflike(1, 0); +int dprintf(int, const char * __restrict, ...) __printflike(2, 3); +int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); + #ifndef __AUDIT__ char* gets(char*) __warnattr("gets is very unsafe; consider using fgets"); int sprintf(char* __restrict, const char* __restrict, ...) @@ -359,21 +362,6 @@ __END_DECLS #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) #endif /* __BSD_VISIBLE */ -#ifdef _GNU_SOURCE -/* - * glibc defines dprintf(int, const char*, ...), which is poorly named - * and likely to conflict with locally defined debugging printfs - * fdprintf is a better name, and some programs that use fdprintf use a - * #define fdprintf dprintf for compatibility - */ -__BEGIN_DECLS -int fdprintf(int, const char*, ...) - __printflike(2, 3); -int vfdprintf(int, const char*, __va_list) - __printflike(2, 0); -__END_DECLS -#endif /* _GNU_SOURCE */ - #if defined(__BIONIC_FORTIFY) __BEGIN_DECLS diff --git a/9/platforms/android-19/arch-mips64/usr/include/sys/cdefs.h b/9/platforms/android-19/arch-mips64/usr/include/sys/cdefs.h index 8ab5b47..37c43cf 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/sys/cdefs.h +++ b/9/platforms/android-19/arch-mips64/usr/include/sys/cdefs.h @@ -38,6 +38,24 @@ #define _SYS_CDEFS_H_ /* + * Testing against Clang-specific extensions. + */ + +#ifndef __has_extension +#define __has_extension __has_feature +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + + +/* * Macro to test if we're using a GNU C compiler of a specific vintage * or later, for e.g. features that appeared in a particular version * of GNU C. Usage: diff --git a/9/platforms/android-19/arch-mips64/usr/include/sys/ucontext.h b/9/platforms/android-19/arch-mips64/usr/include/sys/ucontext.h index f150ac7..d6c6b43 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/sys/ucontext.h +++ b/9/platforms/android-19/arch-mips64/usr/include/sys/ucontext.h @@ -60,8 +60,6 @@ enum { typedef int greg_t; typedef greg_t gregset_t[NGREG]; -/* TODO: fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -71,13 +69,12 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; - /* TODO: uc_regspace */ + char __padding[128 - sizeof(sigset_t)]; + unsigned long uc_regspace[128] __attribute__((__aligned__(8))); } ucontext_t; #elif defined(__aarch64__) -/* TODO: gregset_t and fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -201,6 +198,7 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; + char __padding[128 - sizeof(sigset_t)]; } ucontext_t; #elif defined(__mips64__) diff --git a/9/platforms/android-19/arch-mips64/usr/include/unistd.h b/9/platforms/android-19/arch-mips64/usr/include/unistd.h index 6cb36d8..08a82e6 100644 --- a/9/platforms/android-19/arch-mips64/usr/include/unistd.h +++ b/9/platforms/android-19/arch-mips64/usr/include/unistd.h @@ -207,7 +207,7 @@ extern int setdomainname(const char *, size_t); /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ + __typeof__(exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libc.a b/9/platforms/android-19/arch-mips64/usr/lib/libc.a Binary files differindex afb02c8..e0d9891 100644 --- a/9/platforms/android-19/arch-mips64/usr/lib/libc.a +++ b/9/platforms/android-19/arch-mips64/usr/lib/libc.a diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libc.so b/9/platforms/android-19/arch-mips64/usr/lib/libc.so Binary files differindex dfa294a..ffacae5 100755 --- a/9/platforms/android-19/arch-mips64/usr/lib/libc.so +++ b/9/platforms/android-19/arch-mips64/usr/lib/libc.so diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libdl.so b/9/platforms/android-19/arch-mips64/usr/lib/libdl.so Binary files differindex 0d6cf6f..88f214e 100755 --- a/9/platforms/android-19/arch-mips64/usr/lib/libdl.so +++ b/9/platforms/android-19/arch-mips64/usr/lib/libdl.so diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libm.a b/9/platforms/android-19/arch-mips64/usr/lib/libm.a Binary files differindex 81baa14..c8e877c 100644 --- a/9/platforms/android-19/arch-mips64/usr/lib/libm.a +++ b/9/platforms/android-19/arch-mips64/usr/lib/libm.a diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libm.so b/9/platforms/android-19/arch-mips64/usr/lib/libm.so Binary files differindex 9c278b9..853453b 100755 --- a/9/platforms/android-19/arch-mips64/usr/lib/libm.so +++ b/9/platforms/android-19/arch-mips64/usr/lib/libm.so diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.a b/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.a Binary files differindex 09f242e..aff84b9 100644 --- a/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.a +++ b/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.a diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.so b/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.so Binary files differindex 2a3a354..832471d 100755 --- a/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.so +++ b/9/platforms/android-19/arch-mips64/usr/lib/libstdc++.so diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libz.a b/9/platforms/android-19/arch-mips64/usr/lib/libz.a Binary files differindex 7da18ce..d4a16dd 100644 --- a/9/platforms/android-19/arch-mips64/usr/lib/libz.a +++ b/9/platforms/android-19/arch-mips64/usr/lib/libz.a diff --git a/9/platforms/android-19/arch-mips64/usr/lib/libz.so b/9/platforms/android-19/arch-mips64/usr/lib/libz.so Binary files differnew file mode 100755 index 0000000..6f3c25e --- /dev/null +++ b/9/platforms/android-19/arch-mips64/usr/lib/libz.so diff --git a/9/platforms/android-19/arch-x86_64/usr/include/dlfcn.h b/9/platforms/android-19/arch-x86_64/usr/include/dlfcn.h index 7daa8f7..8dde08c 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/dlfcn.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/dlfcn.h @@ -50,15 +50,29 @@ extern void* dlsym(void* handle, const char* symbol); extern int dladdr(const void* addr, Dl_info *info); enum { +#if defined(__LP64__) + RTLD_NOW = 2, +#else RTLD_NOW = 0, +#endif RTLD_LAZY = 1, RTLD_LOCAL = 0, +#if defined(__LP64__) + RTLD_GLOBAL = 0x00100, +#else RTLD_GLOBAL = 2, +#endif + RTLD_NOLOAD = 4, }; +#if defined (__LP64__) +#define RTLD_DEFAULT ((void*) 0) +#define RTLD_NEXT ((void*) -1L) +#else #define RTLD_DEFAULT ((void*) 0xffffffff) #define RTLD_NEXT ((void*) 0xfffffffe) +#endif __END_DECLS diff --git a/9/platforms/android-19/arch-x86_64/usr/include/fenv.h b/9/platforms/android-19/arch-x86_64/usr/include/fenv.h index 6966e0d..73ecc80 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/fenv.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/fenv.h @@ -34,6 +34,7 @@ #include <machine/fenv.h> __BEGIN_DECLS +#pragma GCC visibility push(default) int feclearexcept(int); int fegetexceptflag(fexcept_t *, int); @@ -64,6 +65,7 @@ int fegetexcept(void); extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) +#pragma GCC visibility pop __END_DECLS #endif /* ! _FENV_H_ */ diff --git a/9/platforms/android-19/arch-x86_64/usr/include/math.h b/9/platforms/android-19/arch-x86_64/usr/include/math.h index c264583..4faec33 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/math.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/math.h @@ -20,6 +20,9 @@ #include <sys/cdefs.h> #include <limits.h> +__BEGIN_DECLS +#pragma GCC visibility push(default) + /* * ANSI/POSIX */ @@ -165,7 +168,7 @@ extern int signgam; * effect of raising floating-point exceptions, so they are not declared * as __pure2. In C99, FENV_ACCESS affects the purity of these functions. */ -__BEGIN_DECLS + /* * ANSI/POSIX */ @@ -282,6 +285,7 @@ double trunc(double); double drem(double, double); int finite(double) __pure2; int isnanf(float) __pure2; +long double significandl(long double); /* * Reentrant version of gamma & lgamma; passes signgam back by reference @@ -464,6 +468,7 @@ void sincosf(float, float*, float*); void sincosl(long double, long double*, long double*); #endif /* _GNU_SOURCE */ +#pragma GCC visibility pop __END_DECLS #endif /* !_MATH_H_ */ diff --git a/9/platforms/android-19/arch-x86_64/usr/include/pthread.h b/9/platforms/android-19/arch-x86_64/usr/include/pthread.h index 49f943a..5c9b626 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/pthread.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/pthread.h @@ -94,16 +94,28 @@ typedef long pthread_condattr_t; typedef long pthread_rwlockattr_t; typedef struct { - pthread_mutex_t lock; - pthread_cond_t cond; - int numLocks; - int writerThreadId; - int pendingReaders; - int pendingWriters; - void* __reserved[4]; +#if !defined(__LP64__) + pthread_mutex_t __unused_lock; + pthread_cond_t __unused_cond; +#endif + volatile int32_t state; // 0=unlock, -1=writer lock, +n=reader lock + volatile int32_t writer_thread_id; + volatile int32_t pending_readers; + volatile int32_t pending_writers; + int32_t attr; +#ifdef __LP64__ + char __reserved[36]; +#else + char __reserved[12]; +#endif + } pthread_rwlock_t; -#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, { NULL, NULL, NULL, NULL } } +#ifdef __LP64__ + #define PTHREAD_RWLOCK_INITIALIZER { 0, 0, 0, 0, 0, { 0 } } +#else + #define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { 0 } } +#endif typedef int pthread_key_t; typedef long pthread_t; diff --git a/9/platforms/android-19/arch-x86_64/usr/include/stdatomic.h b/9/platforms/android-19/arch-x86_64/usr/include/stdatomic.h new file mode 100644 index 0000000..43ec753 --- /dev/null +++ b/9/platforms/android-19/arch-x86_64/usr/include/stdatomic.h @@ -0,0 +1,420 @@ +/*- + * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> + * David Chisnall <theraven@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _STDATOMIC_H_ +#define _STDATOMIC_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <stdbool.h> + +#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#define __CLANG_ATOMICS +#elif __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif defined(__GNUC__) +#define __SYNC_ATOMICS +#else +#error "stdatomic.h does not support your compiler" +#endif + +/* + * 7.17.1 Atomic lock-free macros. + */ + +#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/* + * 7.17.2 Initialization. + */ + +#if defined(__CLANG_ATOMICS) +#define ATOMIC_VAR_INIT(value) (value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#else +#define ATOMIC_VAR_INIT(value) { .__val = (value) } +#define atomic_init(obj, value) ((void)((obj)->__val = (value))) +#endif + +/* + * Clang and recent GCC both provide predefined macros for the memory + * orderings. If we are using a compiler that doesn't define them, use the + * clang values - these will be ignored in the fallback path. + */ + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +/* + * 7.17.3 Order and consistency. + * + * The memory_order_* constants that denote the barrier behaviour of the + * atomic operations. + */ + +typedef enum { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +/* + * 7.17.4 Fences. + */ + +static __inline void +atomic_thread_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_thread_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_thread_fence(__order); +#else + __sync_synchronize(); +#endif +} + +static __inline void +atomic_signal_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_signal_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_signal_fence(__order); +#else + __asm volatile ("" ::: "memory"); +#endif +} + +/* + * 7.17.5 Lock-free property. + */ + +#if defined(_KERNEL) +/* Atomics in kernelspace are always lock-free. */ +#define atomic_is_lock_free(obj) \ + ((void)(obj), (_Bool)1) +#elif defined(__CLANG_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof(*(obj)), obj) +#elif defined(__GNUC_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) +#else +#define atomic_is_lock_free(obj) \ + ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) +#endif + +/* + * 7.17.6 Atomic integer types. + */ + +#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) +/* + * No native support for _Atomic(). Place object in structure to prevent + * most forms of direct non-atomic access. + */ +#define _Atomic(T) struct { T volatile __val; } +#endif + +typedef _Atomic(bool) atomic_bool; +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +typedef _Atomic(char16_t) atomic_char16_t; +typedef _Atomic(char32_t) atomic_char32_t; +typedef _Atomic(wchar_t) atomic_wchar_t; +typedef _Atomic(int_least8_t) atomic_int_least8_t; +typedef _Atomic(uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(int_least16_t) atomic_int_least16_t; +typedef _Atomic(uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(int_least32_t) atomic_int_least32_t; +typedef _Atomic(uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(int_least64_t) atomic_int_least64_t; +typedef _Atomic(uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(intptr_t) atomic_intptr_t; +typedef _Atomic(uintptr_t) atomic_uintptr_t; +typedef _Atomic(size_t) atomic_size_t; +typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(intmax_t) atomic_intmax_t; +typedef _Atomic(uintmax_t) atomic_uintmax_t; + +/* + * 7.17.7 Operations on atomic types. + */ + +/* + * Compiler-specific operations. + */ + +#if defined(__CLANG_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ + success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ + success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __c11_atomic_exchange(object, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __c11_atomic_fetch_add(object, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __c11_atomic_fetch_and(object, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __c11_atomic_fetch_or(object, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __c11_atomic_fetch_sub(object, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __c11_atomic_fetch_xor(object, operand, order) +#define atomic_load_explicit(object, order) \ + __c11_atomic_load(object, order) +#define atomic_store_explicit(object, desired, order) \ + __c11_atomic_store(object, desired, order) +#elif defined(__GNUC_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 0, success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 1, success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __atomic_exchange_n(&(object)->__val, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __atomic_fetch_add(&(object)->__val, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __atomic_fetch_and(&(object)->__val, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __atomic_fetch_or(&(object)->__val, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __atomic_fetch_sub(&(object)->__val, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __atomic_fetch_xor(&(object)->__val, operand, order) +#define atomic_load_explicit(object, order) \ + __atomic_load_n(&(object)->__val, order) +#define atomic_store_explicit(object, desired, order) \ + __atomic_store_n(&(object)->__val, desired, order) +#else +#define __atomic_apply_stride(object, operand) \ + (((__typeof__((object)->__val))0) + (operand)) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) __extension__ ({ \ + __typeof__(expected) __ep = (expected); \ + __typeof__(*__ep) __e = *__ep; \ + (void)(success); (void)(failure); \ + (bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ + __e, desired)) == __e); \ +}) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) +#if __has_builtin(__sync_swap) +/* Clang provides a full-barrier atomic exchange - use it if available. */ +#define atomic_exchange_explicit(object, desired, order) \ + ((void)(order), __sync_swap(&(object)->__val, desired)) +#else +/* + * __sync_lock_test_and_set() is only an acquire barrier in theory (although in + * practice it is usually a full barrier) so we need an explicit barrier before + * it. + */ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o = (object); \ + __typeof__(desired) __d = (desired); \ + (void)(order); \ + __sync_synchronize(); \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ +}) +#endif +#define atomic_fetch_add_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_and_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) +#define atomic_fetch_or_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) +#define atomic_fetch_sub_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_xor_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) +#define atomic_load_explicit(object, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) +#define atomic_store_explicit(object, desired, order) \ + ((void)atomic_exchange_explicit(object, desired, order)) +#endif + +/* + * Convenience functions. + * + * Don't provide these in kernel space. In kernel space, we should be + * disciplined enough to always provide explicit barriers. + */ + +#ifndef _KERNEL +#define atomic_compare_exchange_strong(object, expected, desired) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_weak_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_exchange(object, desired) \ + atomic_exchange_explicit(object, desired, memory_order_seq_cst) +#define atomic_fetch_add(object, operand) \ + atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_and(object, operand) \ + atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_or(object, operand) \ + atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_sub(object, operand) \ + atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_xor(object, operand) \ + atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) +#define atomic_load(object) \ + atomic_load_explicit(object, memory_order_seq_cst) +#define atomic_store(object, desired) \ + atomic_store_explicit(object, desired, memory_order_seq_cst) +#endif /* !_KERNEL */ + +/* + * 7.17.8 Atomic flag type and operations. + * + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some + * kind of compiler built-in type we could use? + */ + +typedef struct { + atomic_bool __flag; +} atomic_flag; + +#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } + +static __inline bool +atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, + memory_order __order) +{ + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); +} + +static __inline void +atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) +{ + + atomic_store_explicit(&__object->__flag, 0, __order); +} + +#ifndef _KERNEL +static __inline bool +atomic_flag_test_and_set(volatile atomic_flag *__object) +{ + + return (atomic_flag_test_and_set_explicit(__object, + memory_order_seq_cst)); +} + +static __inline void +atomic_flag_clear(volatile atomic_flag *__object) +{ + + atomic_flag_clear_explicit(__object, memory_order_seq_cst); +} +#endif /* !_KERNEL */ + +#endif /* !_STDATOMIC_H_ */ diff --git a/9/platforms/android-19/arch-x86_64/usr/include/stdio.h b/9/platforms/android-19/arch-x86_64/usr/include/stdio.h index 1d89b9b..b026843 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/stdio.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/stdio.h @@ -250,6 +250,9 @@ int vfprintf(FILE * __restrict, const char * __restrict, __va_list) int vprintf(const char * __restrict, __va_list) __printflike(1, 0); +int dprintf(int, const char * __restrict, ...) __printflike(2, 3); +int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); + #ifndef __AUDIT__ char* gets(char*) __warnattr("gets is very unsafe; consider using fgets"); int sprintf(char* __restrict, const char* __restrict, ...) @@ -359,21 +362,6 @@ __END_DECLS #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) #endif /* __BSD_VISIBLE */ -#ifdef _GNU_SOURCE -/* - * glibc defines dprintf(int, const char*, ...), which is poorly named - * and likely to conflict with locally defined debugging printfs - * fdprintf is a better name, and some programs that use fdprintf use a - * #define fdprintf dprintf for compatibility - */ -__BEGIN_DECLS -int fdprintf(int, const char*, ...) - __printflike(2, 3); -int vfdprintf(int, const char*, __va_list) - __printflike(2, 0); -__END_DECLS -#endif /* _GNU_SOURCE */ - #if defined(__BIONIC_FORTIFY) __BEGIN_DECLS diff --git a/9/platforms/android-19/arch-x86_64/usr/include/sys/cdefs.h b/9/platforms/android-19/arch-x86_64/usr/include/sys/cdefs.h index 8ab5b47..37c43cf 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/sys/cdefs.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/sys/cdefs.h @@ -38,6 +38,24 @@ #define _SYS_CDEFS_H_ /* + * Testing against Clang-specific extensions. + */ + +#ifndef __has_extension +#define __has_extension __has_feature +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + + +/* * Macro to test if we're using a GNU C compiler of a specific vintage * or later, for e.g. features that appeared in a particular version * of GNU C. Usage: diff --git a/9/platforms/android-19/arch-x86_64/usr/include/sys/ucontext.h b/9/platforms/android-19/arch-x86_64/usr/include/sys/ucontext.h index f150ac7..d6c6b43 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/sys/ucontext.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/sys/ucontext.h @@ -60,8 +60,6 @@ enum { typedef int greg_t; typedef greg_t gregset_t[NGREG]; -/* TODO: fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -71,13 +69,12 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; - /* TODO: uc_regspace */ + char __padding[128 - sizeof(sigset_t)]; + unsigned long uc_regspace[128] __attribute__((__aligned__(8))); } ucontext_t; #elif defined(__aarch64__) -/* TODO: gregset_t and fpregset_t. */ - #include <asm/sigcontext.h> typedef struct sigcontext mcontext_t; @@ -201,6 +198,7 @@ typedef struct ucontext { stack_t uc_stack; mcontext_t uc_mcontext; sigset_t uc_sigmask; + char __padding[128 - sizeof(sigset_t)]; } ucontext_t; #elif defined(__mips64__) diff --git a/9/platforms/android-19/arch-x86_64/usr/include/unistd.h b/9/platforms/android-19/arch-x86_64/usr/include/unistd.h index 6cb36d8..08a82e6 100644 --- a/9/platforms/android-19/arch-x86_64/usr/include/unistd.h +++ b/9/platforms/android-19/arch-x86_64/usr/include/unistd.h @@ -207,7 +207,7 @@ extern int setdomainname(const char *, size_t); /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ + __typeof__(exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libc.a b/9/platforms/android-19/arch-x86_64/usr/lib64/libc.a Binary files differindex bd52a5f..82ee862 100644 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libc.a +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libc.a diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libc.so b/9/platforms/android-19/arch-x86_64/usr/lib64/libc.so Binary files differindex 7a48943..f202ce7 100755 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libc.so +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libc.so diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libdl.so b/9/platforms/android-19/arch-x86_64/usr/lib64/libdl.so Binary files differindex 827b072..79c7a54 100755 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libdl.so +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libdl.so diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libm.a b/9/platforms/android-19/arch-x86_64/usr/lib64/libm.a Binary files differindex f719483..c039f45 100644 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libm.a +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libm.a diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libm.so b/9/platforms/android-19/arch-x86_64/usr/lib64/libm.so Binary files differindex 071945b..c8bfb93 100755 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libm.so +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libm.so diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.a b/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.a Binary files differindex fdc3580..ace8279 100644 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.a +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.a diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.so b/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.so Binary files differindex 1468dd5..7eeba09 100755 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.so +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libstdc++.so diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libz.a b/9/platforms/android-19/arch-x86_64/usr/lib64/libz.a Binary files differindex 3b2c4f2..5919512 100644 --- a/9/platforms/android-19/arch-x86_64/usr/lib64/libz.a +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libz.a diff --git a/9/platforms/android-19/arch-x86_64/usr/lib64/libz.so b/9/platforms/android-19/arch-x86_64/usr/lib64/libz.so Binary files differnew file mode 100755 index 0000000..1820179 --- /dev/null +++ b/9/platforms/android-19/arch-x86_64/usr/lib64/libz.so |