summaryrefslogtreecommitdiffstats
path: root/sys/sys/stdatomic.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2013-06-13 18:40:45 +0000
committered <ed@FreeBSD.org>2013-06-13 18:40:45 +0000
commit31754f3c181fb90c30132ff0cc1df6e95a0be9d9 (patch)
tree6bccc4b30c0ba58fedaff4cf7f390b8b9f316421 /sys/sys/stdatomic.h
parent56067c0e56473f033190cdeaac21c759d835372e (diff)
downloadFreeBSD-src-31754f3c181fb90c30132ff0cc1df6e95a0be9d9.zip
FreeBSD-src-31754f3c181fb90c30132ff0cc1df6e95a0be9d9.tar.gz
Minor improvements to <stdatomic.h>.
- Define __SYNC_ATOMICS in case we're using the __sync_*() API. This is not used by <stdatomic.h> itself, but may be useful for some of the intrinsics code to determine whether it should build the machine-dependent intrinsic functions. - Make is_lock_free() work in kernelspace. For now, assume atomics in kernelspace are always lock free. This is a quite reasonable assumption, as we surely shouldn't implement the atomic fallbacks for arbitrary sizes.
Diffstat (limited to 'sys/sys/stdatomic.h')
-rw-r--r--sys/sys/stdatomic.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h
index 5bf636f..9aceb79 100644
--- a/sys/sys/stdatomic.h
+++ b/sys/sys/stdatomic.h
@@ -37,7 +37,9 @@
#define __CLANG_ATOMICS
#elif __GNUC_PREREQ__(4, 7)
#define __GNUC_ATOMICS
-#elif !defined(__GNUC__)
+#elif defined(__GNUC__)
+#define __SYNC_ATOMICS
+#else
#error "stdatomic.h does not support your compiler"
#endif
@@ -156,7 +158,11 @@ enum memory_order {
* 7.17.5 Lock-free property.
*/
-#if defined(__CLANG_ATOMICS)
+#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)
OpenPOWER on IntegriCloud