Refresh 64-bit headers/libs (WW36)

sync to lmp-dev/bionic 1e010d60397db706cd3d1c4d5701a2bced441aa8

Change-Id: Ieed39d41eb0655d7c8f027bd038be1753a9e56a6
This commit is contained in:
Andrew Hsieh
2014-08-18 02:17:03 +08:00
parent 72bd04795b
commit 3f53b6f2fe
59 changed files with 343 additions and 268 deletions

View File

@@ -31,17 +31,142 @@
#define _STDATOMIC_H_
#include <sys/cdefs.h>
#if defined(__cplusplus) && defined(_USING_LIBCXX)
# ifdef __clang__
# if __has_feature(cxx_atomic)
# define _STDATOMIC_HAVE_ATOMIC
# endif
# else /* gcc */
# if __GNUC_PREREQ(4, 7)
# define _STDATOMIC_HAVE_ATOMIC
# endif
# endif
#endif
#ifdef _STDATOMIC_HAVE_ATOMIC
/* We have a usable C++ <atomic>; use it instead. */
#include <atomic>
#undef _Atomic
/* Also defined by <atomic> for gcc. But not used in macros. */
/* Also a clang intrinsic. */
/* Should not be used by client code before this file is */
/* included. The definitions in <atomic> themselves see */
/* the old definition, as they should. */
/* Client code sees the following definition. */
#define _Atomic(t) std::atomic<t>
using std::atomic_is_lock_free;
using std::atomic_init;
using std::atomic_store;
using std::atomic_store_explicit;
using std::atomic_load;
using std::atomic_load_explicit;
using std::atomic_exchange;
using std::atomic_exchange_explicit;
using std::atomic_compare_exchange_strong;
using std::atomic_compare_exchange_strong_explicit;
using std::atomic_compare_exchange_weak;
using std::atomic_compare_exchange_weak_explicit;
using std::atomic_fetch_add;
using std::atomic_fetch_add_explicit;
using std::atomic_fetch_sub;
using std::atomic_fetch_sub_explicit;
using std::atomic_fetch_or;
using std::atomic_fetch_or_explicit;
using std::atomic_fetch_xor;
using std::atomic_fetch_xor_explicit;
using std::atomic_fetch_and;
using std::atomic_fetch_and_explicit;
using std::atomic_thread_fence;
using std::atomic_signal_fence;
using std::memory_order;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;
using std::atomic_bool;
using std::atomic_char;
using std::atomic_schar;
using std::atomic_uchar;
using std::atomic_short;
using std::atomic_ushort;
using std::atomic_int;
using std::atomic_uint;
using std::atomic_long;
using std::atomic_ulong;
using std::atomic_llong;
using std::atomic_ullong;
using std::atomic_char16_t;
using std::atomic_char32_t;
using std::atomic_wchar_t;
using std::atomic_int_least8_t;
using std::atomic_uint_least8_t;
using std::atomic_int_least16_t;
using std::atomic_uint_least16_t;
using std::atomic_int_least32_t;
using std::atomic_uint_least32_t;
using std::atomic_int_least64_t;
using std::atomic_uint_least64_t;
using std::atomic_int_fast8_t;
using std::atomic_uint_fast8_t;
using std::atomic_int_fast16_t;
using std::atomic_uint_fast16_t;
using std::atomic_int_fast32_t;
using std::atomic_uint_fast32_t;
using std::atomic_int_fast64_t;
using std::atomic_uint_fast64_t;
using std::atomic_intptr_t;
using std::atomic_uintptr_t;
using std::atomic_size_t;
using std::atomic_ptrdiff_t;
using std::atomic_intmax_t;
using std::atomic_uintmax_t;
#else /* <atomic> unavailable, possibly because this is C, not C++ */
#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
/*
* C: Do it ourselves.
* Note that the runtime representation defined here should be compatible
* with the C++ one, i.e. an _Atomic(T) needs to contain the same
* bits as a T.
*/
#include <stddef.h> /* For ptrdiff_t. */
#include <stdint.h> /* TODO: Should pollute namespace less. */
#if __STDC_VERSION__ >= 201112L
# include <uchar.h> /* For char16_t and char32_t. */
#endif
#ifdef __clang__
# if __has_extension(c_atomic) || __has_extension(cxx_atomic)
# define __CLANG_ATOMICS
# else
# error "stdatomic.h does not support your compiler"
# endif
# if __has_builtin(__sync_swap)
# define __HAS_BUILTIN_SYNC_SWAP
# endif
#else
#error "stdatomic.h does not support your compiler"
# if __GNUC_PREREQ(4, 7)
# define __GNUC_ATOMICS
# else
# define __SYNC_ATOMICS
# ifdef __cplusplus
# define __ATOMICS_AVOID_DOT_INIT
# endif
# endif
#endif
/*
@@ -50,33 +175,53 @@
#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_BOOL_LOCK_FREE 2 /* For all modern platforms */
#endif
#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_CHAR_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_CHAR16_T_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_CHAR32_T_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_WCHAR_T_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_SHORT_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_INT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_INT_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_LONG_LOCK_FREE 2
#endif
#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_LLONG_LOCK_FREE 1 /* maybe */
#endif
#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#elif defined(__SYNC_ATOMICS)
#define ATOMIC_POINTER_LOCK_FREE 2
#endif
/*
@@ -87,7 +232,11 @@
#define ATOMIC_VAR_INIT(value) (value)
#define atomic_init(obj, value) __c11_atomic_init(obj, value)
#else
#ifdef __ATOMICS_AVOID_DOT_INIT
#define ATOMIC_VAR_INIT(value) { value }
#else
#define ATOMIC_VAR_INIT(value) { .__val = (value) }
#endif
#define atomic_init(obj, value) ((void)((obj)->__val = (value)))
#endif
@@ -121,6 +270,8 @@
*
* The memory_order_* constants that denote the barrier behaviour of the
* atomic operations.
* The enum values must be identical to those used by the
* C++ <atomic> header.
*/
typedef enum {
@@ -137,7 +288,7 @@ typedef enum {
*/
static __inline void
atomic_thread_fence(memory_order __order __unused)
atomic_thread_fence(memory_order __order __attribute__((unused)))
{
#ifdef __CLANG_ATOMICS
@@ -150,7 +301,7 @@ atomic_thread_fence(memory_order __order __unused)
}
static __inline void
atomic_signal_fence(memory_order __order __unused)
atomic_signal_fence(memory_order __order __attribute__((unused)))
{
#ifdef __CLANG_ATOMICS
@@ -172,7 +323,7 @@ atomic_signal_fence(memory_order __order __unused)
((void)(obj), (_Bool)1)
#elif defined(__CLANG_ATOMICS)
#define atomic_is_lock_free(obj) \
__atomic_is_lock_free(sizeof(*(obj)), obj)
__c11_atomic_is_lock_free(sizeof(*(obj)))
#elif defined(__GNUC_ATOMICS)
#define atomic_is_lock_free(obj) \
__atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val)
@@ -185,7 +336,7 @@ atomic_signal_fence(memory_order __order __unused)
* 7.17.6 Atomic integer types.
*/
#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
#ifndef __CLANG_ATOMICS
/*
* No native support for _Atomic(). Place object in structure to prevent
* most forms of direct non-atomic access.
@@ -306,7 +457,7 @@ typedef _Atomic(uintmax_t) atomic_uintmax_t;
desired, success, failure) \
atomic_compare_exchange_strong_explicit(object, expected, \
desired, success, failure)
#if __has_builtin(__sync_swap)
#ifdef __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))
@@ -386,7 +537,7 @@ typedef struct {
atomic_bool __flag;
} atomic_flag;
#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) }
#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(false) }
static __inline bool
atomic_flag_test_and_set_explicit(volatile atomic_flag *__object,
@@ -419,4 +570,6 @@ atomic_flag_clear(volatile atomic_flag *__object)
}
#endif /* !_KERNEL */
#endif /* <atomic> unavailable */
#endif /* !_STDATOMIC_H_ */