summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2014-08-19 16:14:01 -0700
committerHans Boehm <hboehm@google.com>2014-09-02 10:32:33 -0700
commitc8cf3513ecb265ba3aadc846aa2113290a504c44 (patch)
tree087fc68abafe155789abe2f966c27941973be902 /libc
parentc191a8adee7ff000b6dd71ee336a12118e2a4733 (diff)
downloadbionic-c8cf3513ecb265ba3aadc846aa2113290a504c44.zip
bionic-c8cf3513ecb265ba3aadc846aa2113290a504c44.tar.gz
bionic-c8cf3513ecb265ba3aadc846aa2113290a504c44.tar.bz2
Fix, generalize stdatomic.h; improve test.
We seem to use this stdatomic.h sometimes, and slightly different prebuilts at other times, making them all difficult to test, and making it unclear which one we're testing. This generalizes the bionic header so that it can be used directly as the prebuilt header as well. So long as they don't diverge again, that should somewhat improve test coverage. Use the correct builtin for atomic_is_lock_free. Fix atomic_flag_init. Turn on atomic tests even with __GLIBC__, since they now appear to pass. Include uchar.h in stdatomic.h where needed. Add a basic memory ordering test. Fix bit-rotted comments in bionic tests makefile. Prerequisite for fixing b/16880454 and Bug:16513433 Change-Id: If6a14c1075b379395ba5d93357d56025c0ffab68 (cherry picked from commit 00aaea364501b3b0abe58dae461136159df1e356)
Diffstat (limited to 'libc')
-rw-r--r--libc/include/stdatomic.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/libc/include/stdatomic.h b/libc/include/stdatomic.h
index 6854d8b..e5420ff 100644
--- a/libc/include/stdatomic.h
+++ b/libc/include/stdatomic.h
@@ -123,6 +123,12 @@ using std::atomic_uintmax_t;
* 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
+
#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
#define __CLANG_ATOMICS
#elif __GNUC_PREREQ(4, 7)
@@ -228,7 +234,7 @@ typedef enum {
*/
static __inline void
-atomic_thread_fence(memory_order __order __unused)
+atomic_thread_fence(memory_order __order __attribute__((unused)))
{
#ifdef __CLANG_ATOMICS
@@ -241,7 +247,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
@@ -263,7 +269,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)
@@ -477,7 +483,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,