atomic: Add plain atomic_load/store_bool()
Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36078
This commit is contained in:
parent
3ba8e9dc4a
commit
2bed73739a
@ -39,6 +39,10 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define __atomic_load_bool_relaxed(p) (*(volatile _Bool *)(p))
|
||||
#define __atomic_store_bool_relaxed(p, v) \
|
||||
(*(volatile _Bool *)(p) = (_Bool)(v))
|
||||
|
||||
#define __atomic_load_char_relaxed(p) (*(volatile u_char *)(p))
|
||||
#define __atomic_load_short_relaxed(p) (*(volatile u_short *)(p))
|
||||
#define __atomic_load_int_relaxed(p) (*(volatile u_int *)(p))
|
||||
@ -70,6 +74,11 @@
|
||||
*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
|
||||
__has_extension(c_generic_selections)
|
||||
#define atomic_load_bool(p) \
|
||||
_Generic(*(p), _Bool: __atomic_load_bool_relaxed(p))
|
||||
#define atomic_store_bool(p, v) \
|
||||
_Generic(*(p), _Bool: __atomic_store_bool_relaxed(p, v))
|
||||
|
||||
#define __atomic_load_generic(p, t, ut, n) \
|
||||
_Generic(*(p), \
|
||||
t: __atomic_load_ ## n ## _relaxed(p), ut: __atomic_load_ ## n ## _relaxed(p))
|
||||
@ -77,6 +86,8 @@
|
||||
_Generic(*(p), \
|
||||
t: __atomic_store_ ## n ## _relaxed(p, v), ut: __atomic_store_ ## n ## _relaxed(p, v))
|
||||
#else
|
||||
#define atomic_load_bool(p) __atomic_load_bool_relaxed(p)
|
||||
#define atomic_store_bool(p, v) __atomic_store_bool_relaxed(p, v)
|
||||
#define __atomic_load_generic(p, t, ut, n) __atomic_load_ ## n ## _relaxed(p)
|
||||
#define __atomic_store_generic(p, v, t, ut, n) __atomic_store_ ## n ## _relaxed(p, v)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user