X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fimpatomic.h;h=55486197c74c2834ac58b6a8ab507529835212f6;hb=66da4eeb0b6c0e3cce5ef7788eb64151e536d68d;hp=0122c69602b33ca0b6231821f74d012468f1e884;hpb=9593acf48b245704a75d0e115d6dec1baf51f07c;p=model-checker.git diff --git a/include/impatomic.h b/include/impatomic.h index 0122c69..5548619 100644 --- a/include/impatomic.h +++ b/include/impatomic.h @@ -1,8 +1,21 @@ +/** + * @file impatomic.h + * @brief Common header for C11/C++11 atomics + * + * Note that some features are unavailable, as they require support from a true + * C11/C++11 compiler. + */ + +#ifndef __IMPATOMIC_H__ +#define __IMPATOMIC_H__ + #include "memoryorder.h" #include "cmodelint.h" #ifdef __cplusplus namespace std { +#else +#include #endif #define CPP0X( feature ) @@ -12,7 +25,6 @@ typedef struct atomic_flag #ifdef __cplusplus bool test_and_set( memory_order = memory_order_seq_cst ) volatile; void clear( memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; CPP0X( atomic_flag() = default; ) CPP0X( atomic_flag( const atomic_flag& ) = delete; ) @@ -35,8 +47,6 @@ extern bool atomic_flag_test_and_set_explicit extern void atomic_flag_clear( volatile atomic_flag* ); extern void atomic_flag_clear_explicit ( volatile atomic_flag*, memory_order ); -extern void atomic_flag_fence -( const volatile atomic_flag*, memory_order ); extern void __atomic_flag_wait__ ( volatile atomic_flag* ); extern void __atomic_flag_wait_explicit__ @@ -54,9 +64,6 @@ inline bool atomic_flag::test_and_set( memory_order __x__ ) volatile inline void atomic_flag::clear( memory_order __x__ ) volatile { atomic_flag_clear_explicit( this, __x__ ); } -inline void atomic_flag::fence( memory_order __x__ ) const volatile -{ atomic_flag_fence( this, __x__ ); } - #endif @@ -113,7 +120,7 @@ inline void atomic_flag::fence( memory_order __x__ ) const volatile else { model_rmwc_action((void *)__p__, __x__); *__q__ = __t__; __r__ = false;} \ __r__; }) -#define _ATOMIC_FENCE_( __a__, __x__ ) \ +#define _ATOMIC_FENCE_( __x__ ) \ ({ model_fence_action(__x__);}) @@ -140,7 +147,6 @@ typedef struct atomic_bool memory_order = memory_order_seq_cst) volatile; bool compare_exchange_strong ( bool&, bool, memory_order = memory_order_seq_cst) volatile; - void fence( memory_order ) const volatile; CPP0X( atomic_bool() = delete; ) CPP0X( constexpr explicit atomic_bool( bool __v__ ) : __f__( __v__ ) { } ) @@ -159,7 +165,6 @@ typedef struct atomic_bool memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_bool*, bool*, bool, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_bool*, memory_order ); CPP0X(private:) #endif @@ -180,7 +185,6 @@ typedef struct atomic_address memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( void*&, void*, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; void* fetch_add( ptrdiff_t, memory_order = memory_order_seq_cst ) volatile; void* fetch_sub( ptrdiff_t, memory_order = memory_order_seq_cst ) volatile; @@ -207,7 +211,6 @@ typedef struct atomic_address void**, void*, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_address*, void**, void*, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_address*, memory_order ); friend void* atomic_fetch_add_explicit( volatile atomic_address*, ptrdiff_t, memory_order ); friend void* atomic_fetch_sub_explicit( volatile atomic_address*, ptrdiff_t, @@ -236,7 +239,6 @@ typedef struct atomic_char memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( char&, char, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; char fetch_add( char, memory_order = memory_order_seq_cst ) volatile; char fetch_sub( char, @@ -293,7 +295,6 @@ typedef struct atomic_char char*, char, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_char*, char*, char, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_char*, memory_order ); friend char atomic_fetch_add_explicit( volatile atomic_char*, char, memory_order ); friend char atomic_fetch_sub_explicit( volatile atomic_char*, @@ -328,7 +329,6 @@ typedef struct atomic_schar memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( signed char&, signed char, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; signed char fetch_add( signed char, memory_order = memory_order_seq_cst ) volatile; signed char fetch_sub( signed char, @@ -385,7 +385,6 @@ typedef struct atomic_schar signed char*, signed char, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_schar*, signed char*, signed char, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_schar*, memory_order ); friend signed char atomic_fetch_add_explicit( volatile atomic_schar*, signed char, memory_order ); friend signed char atomic_fetch_sub_explicit( volatile atomic_schar*, @@ -420,7 +419,6 @@ typedef struct atomic_uchar memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( unsigned char&, unsigned char, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; unsigned char fetch_add( unsigned char, memory_order = memory_order_seq_cst ) volatile; unsigned char fetch_sub( unsigned char, @@ -477,7 +475,6 @@ typedef struct atomic_uchar unsigned char*, unsigned char, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_uchar*, unsigned char*, unsigned char, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_uchar*, memory_order ); friend unsigned char atomic_fetch_add_explicit( volatile atomic_uchar*, unsigned char, memory_order ); friend unsigned char atomic_fetch_sub_explicit( volatile atomic_uchar*, @@ -512,7 +509,6 @@ typedef struct atomic_short memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( short&, short, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; short fetch_add( short, memory_order = memory_order_seq_cst ) volatile; short fetch_sub( short, @@ -569,7 +565,6 @@ typedef struct atomic_short short*, short, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_short*, short*, short, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_short*, memory_order ); friend short atomic_fetch_add_explicit( volatile atomic_short*, short, memory_order ); friend short atomic_fetch_sub_explicit( volatile atomic_short*, @@ -604,7 +599,6 @@ typedef struct atomic_ushort memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( unsigned short&, unsigned short, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; unsigned short fetch_add( unsigned short, memory_order = memory_order_seq_cst ) volatile; unsigned short fetch_sub( unsigned short, @@ -661,7 +655,6 @@ typedef struct atomic_ushort unsigned short*, unsigned short, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_ushort*, unsigned short*, unsigned short, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_ushort*, memory_order ); friend unsigned short atomic_fetch_add_explicit( volatile atomic_ushort*, unsigned short, memory_order ); friend unsigned short atomic_fetch_sub_explicit( volatile atomic_ushort*, @@ -696,7 +689,6 @@ typedef struct atomic_int memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( int&, int, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; int fetch_add( int, memory_order = memory_order_seq_cst ) volatile; int fetch_sub( int, @@ -753,7 +745,6 @@ typedef struct atomic_int int*, int, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_int*, int*, int, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_int*, memory_order ); friend int atomic_fetch_add_explicit( volatile atomic_int*, int, memory_order ); friend int atomic_fetch_sub_explicit( volatile atomic_int*, @@ -788,7 +779,6 @@ typedef struct atomic_uint memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( unsigned int&, unsigned int, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; unsigned int fetch_add( unsigned int, memory_order = memory_order_seq_cst ) volatile; unsigned int fetch_sub( unsigned int, @@ -845,7 +835,6 @@ typedef struct atomic_uint unsigned int*, unsigned int, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_uint*, unsigned int*, unsigned int, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_uint*, memory_order ); friend unsigned int atomic_fetch_add_explicit( volatile atomic_uint*, unsigned int, memory_order ); friend unsigned int atomic_fetch_sub_explicit( volatile atomic_uint*, @@ -880,7 +869,6 @@ typedef struct atomic_long memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( long&, long, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; long fetch_add( long, memory_order = memory_order_seq_cst ) volatile; long fetch_sub( long, @@ -937,7 +925,6 @@ typedef struct atomic_long long*, long, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_long*, long*, long, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_long*, memory_order ); friend long atomic_fetch_add_explicit( volatile atomic_long*, long, memory_order ); friend long atomic_fetch_sub_explicit( volatile atomic_long*, @@ -972,7 +959,6 @@ typedef struct atomic_ulong memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( unsigned long&, unsigned long, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; unsigned long fetch_add( unsigned long, memory_order = memory_order_seq_cst ) volatile; unsigned long fetch_sub( unsigned long, @@ -1029,7 +1015,6 @@ typedef struct atomic_ulong unsigned long*, unsigned long, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_ulong*, unsigned long*, unsigned long, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_ulong*, memory_order ); friend unsigned long atomic_fetch_add_explicit( volatile atomic_ulong*, unsigned long, memory_order ); friend unsigned long atomic_fetch_sub_explicit( volatile atomic_ulong*, @@ -1064,7 +1049,6 @@ typedef struct atomic_llong memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( long long&, long long, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; long long fetch_add( long long, memory_order = memory_order_seq_cst ) volatile; long long fetch_sub( long long, @@ -1121,7 +1105,6 @@ typedef struct atomic_llong long long*, long long, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_llong*, long long*, long long, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_llong*, memory_order ); friend long long atomic_fetch_add_explicit( volatile atomic_llong*, long long, memory_order ); friend long long atomic_fetch_sub_explicit( volatile atomic_llong*, @@ -1156,7 +1139,6 @@ typedef struct atomic_ullong memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( unsigned long long&, unsigned long long, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; unsigned long long fetch_add( unsigned long long, memory_order = memory_order_seq_cst ) volatile; unsigned long long fetch_sub( unsigned long long, @@ -1213,7 +1195,6 @@ typedef struct atomic_ullong unsigned long long*, unsigned long long, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_ullong*, unsigned long long*, unsigned long long, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_ullong*, memory_order ); friend unsigned long long atomic_fetch_add_explicit( volatile atomic_ullong*, unsigned long long, memory_order ); friend unsigned long long atomic_fetch_sub_explicit( volatile atomic_ullong*, @@ -1280,7 +1261,6 @@ typedef struct atomic_wchar_t memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( wchar_t&, wchar_t, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; wchar_t fetch_add( wchar_t, memory_order = memory_order_seq_cst ) volatile; wchar_t fetch_sub( wchar_t, @@ -1337,7 +1317,6 @@ typedef struct atomic_wchar_t wchar_t*, wchar_t, memory_order, memory_order ); friend bool atomic_compare_exchange_strong_explicit( volatile atomic_wchar_t*, wchar_t*, wchar_t, memory_order, memory_order ); - friend void atomic_fence( const volatile atomic_wchar_t*, memory_order ); friend wchar_t atomic_fetch_add_explicit( volatile atomic_wchar_t*, wchar_t, memory_order ); friend wchar_t atomic_fetch_sub_explicit( volatile atomic_wchar_t*, @@ -1379,7 +1358,6 @@ struct atomic bool compare_exchange_strong( T&, T, memory_order, memory_order ) volatile; bool compare_exchange_weak( T&, T, memory_order = memory_order_seq_cst ) volatile; bool compare_exchange_strong( T&, T, memory_order = memory_order_seq_cst ) volatile; - void fence( memory_order ) const volatile; CPP0X( atomic() = default; ) CPP0X( constexpr explicit atomic( T __v__ ) : __f__( __v__ ) { } ) @@ -1642,6 +1620,10 @@ inline bool atomic_load_explicit inline bool atomic_load ( volatile atomic_bool* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_bool* __a__, bool __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_bool* __a__, bool __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1678,10 +1660,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_bool* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_address* __a__ ) { return false; } @@ -1693,6 +1671,10 @@ inline void* atomic_load_explicit inline void* atomic_load( volatile atomic_address* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_address* __a__, void* __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_address* __a__, void* __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1729,10 +1711,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_address* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_char* __a__ ) { return false; } @@ -1744,6 +1722,10 @@ inline char atomic_load_explicit inline char atomic_load( volatile atomic_char* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_char* __a__, char __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_char* __a__, char __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1780,10 +1762,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_char* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_schar* __a__ ) { return false; } @@ -1795,6 +1773,10 @@ inline signed char atomic_load_explicit inline signed char atomic_load( volatile atomic_schar* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_schar* __a__, signed char __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_schar* __a__, signed char __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1831,10 +1813,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_schar* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_uchar* __a__ ) { return false; } @@ -1846,6 +1824,10 @@ inline unsigned char atomic_load_explicit inline unsigned char atomic_load( volatile atomic_uchar* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_uchar* __a__, unsigned char __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_uchar* __a__, unsigned char __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1882,10 +1864,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_uchar* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_short* __a__ ) { return false; } @@ -1897,6 +1875,10 @@ inline short atomic_load_explicit inline short atomic_load( volatile atomic_short* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_short* __a__, short __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_short* __a__, short __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1933,10 +1915,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_short* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_ushort* __a__ ) { return false; } @@ -1948,6 +1926,10 @@ inline unsigned short atomic_load_explicit inline unsigned short atomic_load( volatile atomic_ushort* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_ushort* __a__, unsigned short __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_ushort* __a__, unsigned short __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -1984,10 +1966,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_ushort* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_int* __a__ ) { return false; } @@ -1999,6 +1977,10 @@ inline int atomic_load_explicit inline int atomic_load( volatile atomic_int* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_int* __a__, int __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_int* __a__, int __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2035,10 +2017,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_int* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_uint* __a__ ) { return false; } @@ -2050,6 +2028,10 @@ inline unsigned int atomic_load_explicit inline unsigned int atomic_load( volatile atomic_uint* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_uint* __a__, unsigned int __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_uint* __a__, unsigned int __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2086,10 +2068,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_uint* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_long* __a__ ) { return false; } @@ -2101,6 +2079,10 @@ inline long atomic_load_explicit inline long atomic_load( volatile atomic_long* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_long* __a__, long __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_long* __a__, long __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2137,10 +2119,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_long* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_ulong* __a__ ) { return false; } @@ -2152,6 +2130,10 @@ inline unsigned long atomic_load_explicit inline unsigned long atomic_load( volatile atomic_ulong* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_ulong* __a__, unsigned long __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_ulong* __a__, unsigned long __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2188,10 +2170,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_ulong* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_llong* __a__ ) { return false; } @@ -2203,6 +2181,10 @@ inline long long atomic_load_explicit inline long long atomic_load( volatile atomic_llong* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_llong* __a__, long long __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_llong* __a__, long long __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2239,10 +2221,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_llong* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_ullong* __a__ ) { return false; } @@ -2254,6 +2232,10 @@ inline unsigned long long atomic_load_explicit inline unsigned long long atomic_load( volatile atomic_ullong* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_ullong* __a__, unsigned long long __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_ullong* __a__, unsigned long long __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2290,10 +2272,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_ullong* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline bool atomic_is_lock_free( const volatile atomic_wchar_t* __a__ ) { return false; } @@ -2305,6 +2283,10 @@ inline wchar_t atomic_load_explicit inline wchar_t atomic_load( volatile atomic_wchar_t* __a__ ) { return atomic_load_explicit( __a__, memory_order_seq_cst ); } +inline void atomic_init +( volatile atomic_wchar_t* __a__, wchar_t __m__ ) +{ _ATOMIC_INIT_( __a__, __m__ ); } + inline void atomic_store_explicit ( volatile atomic_wchar_t* __a__, wchar_t __m__, memory_order __x__ ) { _ATOMIC_STORE_( __a__, __m__, __x__ ); } @@ -2341,10 +2323,6 @@ inline bool atomic_compare_exchange_strong { return atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, memory_order_seq_cst, memory_order_seq_cst ); } -inline void atomic_fence -( const volatile atomic_wchar_t* __a__, memory_order __x__ ) -{ _ATOMIC_FENCE_( __a__, __x__ ); } - inline void* atomic_fetch_add_explicit ( volatile atomic_address* __a__, ptrdiff_t __m__, memory_order __x__ ) @@ -2950,9 +2928,6 @@ _ATOMIC_CMPSWP_WEAK_( __a__, __e__, __m__, __x__ ) #define atomic_compare_exchange_strong_explicit( __a__, __e__, __m__, __x__, __y__ ) \ _ATOMIC_CMPSWP_( __a__, __e__, __m__, __x__ ) -#define atomic_fence( __a__, __x__ ) \ -({ _ATOMIC_FENCE_( __a__, __x__ ); }) - #define atomic_fetch_add_explicit( __a__, __m__, __x__ ) \ _ATOMIC_MODIFY_( __a__, +=, __m__, __x__ ) @@ -3032,10 +3007,6 @@ inline bool atomic_bool::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_bool::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_address::is_lock_free() const volatile { return false; } @@ -3074,10 +3045,6 @@ inline bool atomic_address::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_address::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_char::is_lock_free() const volatile { return false; } @@ -3116,10 +3083,6 @@ inline bool atomic_char::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_char::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_schar::is_lock_free() const volatile { return false; } @@ -3158,10 +3121,6 @@ inline bool atomic_schar::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_schar::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_uchar::is_lock_free() const volatile { return false; } @@ -3200,10 +3159,6 @@ inline bool atomic_uchar::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_uchar::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_short::is_lock_free() const volatile { return false; } @@ -3242,10 +3197,6 @@ inline bool atomic_short::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_short::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_ushort::is_lock_free() const volatile { return false; } @@ -3284,10 +3235,6 @@ inline bool atomic_ushort::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_ushort::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_int::is_lock_free() const volatile { return false; } @@ -3326,10 +3273,6 @@ inline bool atomic_int::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_int::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_uint::is_lock_free() const volatile { return false; } @@ -3368,10 +3311,6 @@ inline bool atomic_uint::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_uint::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_long::is_lock_free() const volatile { return false; } @@ -3410,10 +3349,6 @@ inline bool atomic_long::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_long::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_ulong::is_lock_free() const volatile { return false; } @@ -3452,10 +3387,6 @@ inline bool atomic_ulong::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_ulong::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_llong::is_lock_free() const volatile { return false; } @@ -3494,10 +3425,6 @@ inline bool atomic_llong::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_llong::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_ullong::is_lock_free() const volatile { return false; } @@ -3536,10 +3463,6 @@ inline bool atomic_ullong::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_ullong::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - inline bool atomic_wchar_t::is_lock_free() const volatile { return false; } @@ -3578,10 +3501,6 @@ inline bool atomic_wchar_t::compare_exchange_strong __x__ == memory_order_acq_rel ? memory_order_acquire : __x__ == memory_order_release ? memory_order_relaxed : __x__ ); } -inline void atomic_wchar_t::fence -( memory_order __x__ ) const volatile -{ return atomic_fence( this, __x__ ); } - template< typename T > inline bool atomic::is_lock_free() const volatile @@ -3980,8 +3899,22 @@ T* atomic::fetch_sub( ptrdiff_t __v__, memory_order __x__ ) volatile #endif +#ifdef __cplusplus +extern "C" { +#endif +static inline void atomic_thread_fence(memory_order order) +{ _ATOMIC_FENCE_(order); } + +/** @todo Do we want to try to support a user's signal-handler? */ +static inline void atomic_signal_fence(memory_order order) +{ /* No-op? */ } +#ifdef __cplusplus +} +#endif + #ifdef __cplusplus } // namespace std #endif +#endif /* __IMPATOMIC_H__ */