svn commit: r254606 - in stable/9: include sys/sys
Tijl Coosemans
tijl at FreeBSD.org
Wed Aug 21 19:02:35 UTC 2013
Author: tijl
Date: Wed Aug 21 19:02:34 2013
New Revision: 254606
URL: http://svnweb.freebsd.org/changeset/base/254606
Log:
MFC r241077:
- Simplify the implementation of atomic_compare_exchange_strong_explicit.
- Evaluate the memory order argument in atomic_fetch_*_explicit macros.
- Implement atomic_store_explicit using atomic_exchange_explicit instead
of a plain assignment.
MFC r241190:
Define clang feature test macro __has_extension. It's used in stdatomic.h.
MFC r254497:
Change the return type of the fallback implementation of the
atomic_compare_exchange_* macros in stdatomic.h to _Bool.
Modified:
stable/9/include/stdatomic.h
stable/9/sys/sys/cdefs.h
Directory Properties:
stable/9/include/ (props changed)
stable/9/sys/ (props changed)
stable/9/sys/sys/ (props changed)
Modified: stable/9/include/stdatomic.h
==============================================================================
--- stable/9/include/stdatomic.h Wed Aug 21 18:12:04 2013 (r254605)
+++ stable/9/include/stdatomic.h Wed Aug 21 19:02:34 2013 (r254606)
@@ -234,19 +234,12 @@ typedef _Atomic(__uintmax_t) atomic_uin
#else
#define atomic_compare_exchange_strong_explicit(object, expected, \
desired, success, failure) __extension__ ({ \
- __typeof__((object)->__val) __v; \
- __typeof__(expected) __e; \
- _Bool __r; \
- __e = (expected); \
- (void)(success); \
- (void)(failure); \
- __v = __sync_val_compare_and_swap(&(object)->__val, \
- *__e, (desired)); \
- __r = (*__e == __v); \
- *__e = __v; \
- __r; \
+ __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, \
@@ -271,25 +264,19 @@ __extension__ ({ \
})
#endif
#define atomic_fetch_add_explicit(object, operand, order) \
- __sync_fetch_and_add(&(object)->__val, operand)
+ ((void)(order), __sync_fetch_and_add(&(object)->__val, operand))
#define atomic_fetch_and_explicit(object, operand, order) \
- __sync_fetch_and_and(&(object)->__val, operand)
+ ((void)(order), __sync_fetch_and_and(&(object)->__val, operand))
#define atomic_fetch_or_explicit(object, operand, order) \
- __sync_fetch_and_or(&(object)->__val, operand)
+ ((void)(order), __sync_fetch_and_or(&(object)->__val, operand))
#define atomic_fetch_sub_explicit(object, operand, order) \
- __sync_fetch_and_sub(&(object)->__val, operand)
+ ((void)(order), __sync_fetch_and_sub(&(object)->__val, operand))
#define atomic_fetch_xor_explicit(object, operand, order) \
- __sync_fetch_and_xor(&(object)->__val, operand)
+ ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand))
#define atomic_load_explicit(object, order) \
- __sync_fetch_and_add(&(object)->__val, 0)
-#define atomic_store_explicit(object, desired, order) __extension__ ({ \
- __typeof__(object) __o = (object); \
- __typeof__(desired) __d = (desired); \
- (void)(order); \
- __sync_synchronize(); \
- __o->__val = __d; \
- __sync_synchronize(); \
-})
+ ((void)(order), __sync_fetch_and_add(&(object)->__val, 0))
+#define atomic_store_explicit(object, desired, order) \
+ ((void)atomic_exchange_explicit(object, desired, order))
#endif
/*
Modified: stable/9/sys/sys/cdefs.h
==============================================================================
--- stable/9/sys/sys/cdefs.h Wed Aug 21 18:12:04 2013 (r254605)
+++ stable/9/sys/sys/cdefs.h Wed Aug 21 19:02:34 2013 (r254606)
@@ -676,6 +676,9 @@
#endif
#endif
+#ifndef __has_extension
+#define __has_extension __has_feature
+#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
More information about the svn-src-stable-9
mailing list