diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-13 15:38:52 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-14 10:28:30 +0100 |
commit | 945853b7cf35f55fc8a749aa106bd77a491fe125 (patch) | |
tree | 39ddfeacb800f0a7df9bb2de4487dfe1347bddec /cpukit/score/include/rtems/score/cpustdatomic.h | |
parent | score: Fix warnings, C++ compatibility, fix typos (diff) | |
download | rtems-945853b7cf35f55fc8a749aa106bd77a491fe125.tar.bz2 |
score: Add Atomic_Uint
Diffstat (limited to 'cpukit/score/include/rtems/score/cpustdatomic.h')
-rw-r--r-- | cpukit/score/include/rtems/score/cpustdatomic.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h index e545dc02c6..e364eb945e 100644 --- a/cpukit/score/include/rtems/score/cpustdatomic.h +++ b/cpukit/score/include/rtems/score/cpustdatomic.h @@ -35,6 +35,11 @@ extern "C" { /** * @brief atomic operation unsigned integer type */ +typedef atomic_uint Atomic_Uint; + +/** + * @brief atomic operation unsigned long integer type + */ typedef atomic_ulong Atomic_Ulong; /** @@ -71,6 +76,7 @@ typedef enum { /** * @brief atomic data initializer for static initialization. */ +#define CPU_ATOMIC_INITIALIZER_UINT(value) ATOMIC_VAR_INIT(value) #define CPU_ATOMIC_INITIALIZER_ULONG(value) ATOMIC_VAR_INIT(value) #define CPU_ATOMIC_INITIALIZER_PTR(pointer) \ ATOMIC_VAR_INIT((uintptr_t) pointer) @@ -83,6 +89,14 @@ typedef enum { * @param object an atomic type pointer of object. * @param value a value to be stored into object. */ +static inline void _CPU_atomic_Init_uint( + volatile Atomic_Uint *object, + unsigned int value +) +{ + atomic_init( object, value ); +} + static inline void _CPU_atomic_Init_ulong( volatile Atomic_Ulong *object, unsigned long value @@ -107,6 +121,14 @@ static inline void _CPU_atomic_Init_ptr( * * The order shall not be ATOMIC_ORDER_RELEASE. */ +static inline unsigned int _CPU_atomic_Load_uint( + volatile Atomic_Uint *object, + Atomic_Order order +) +{ + return atomic_load_explicit( object, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Load_ulong( volatile Atomic_Ulong *object, Atomic_Order order @@ -132,6 +154,15 @@ static inline void *_CPU_atomic_Load_ptr( * * The order shall not be ATOMIC_ORDER_ACQUIRE. */ +static inline void _CPU_atomic_Store_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + atomic_store_explicit( object, value, (memory_order) order ); +} + static inline void _CPU_atomic_Store_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -159,6 +190,15 @@ static inline void _CPU_atomic_Store_ptr( * * @retval a result value before add ops. */ +static inline unsigned int _CPU_atomic_Fetch_add_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + return atomic_fetch_add_explicit( object, value, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Fetch_add_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -186,6 +226,15 @@ static inline uintptr_t _CPU_atomic_Fetch_add_ptr( * * @retval a result value before sub ops. */ +static inline unsigned int _CPU_atomic_Fetch_sub_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + return atomic_fetch_sub_explicit( object, value, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Fetch_sub_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -213,6 +262,15 @@ static inline uintptr_t _CPU_atomic_Fetch_sub_ptr( * * @retval a result value before or ops. */ +static inline unsigned int _CPU_atomic_Fetch_or_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + return atomic_fetch_or_explicit( object, value, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Fetch_or_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -240,6 +298,15 @@ static inline uintptr_t _CPU_atomic_Fetch_or_ptr( * * @retval a result value before and ops. */ +static inline unsigned int _CPU_atomic_Fetch_and_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + return atomic_fetch_and_explicit( object, value, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Fetch_and_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -267,6 +334,15 @@ static inline uintptr_t _CPU_atomic_Fetch_and_ptr( * * @retval a result value before exchange ops. */ +static inline unsigned int _CPU_atomic_Exchange_uint( + volatile Atomic_Uint *object, + unsigned int value, + Atomic_Order order +) +{ + return atomic_exchange_explicit( object, value, (memory_order) order ); +} + static inline unsigned long _CPU_atomic_Exchange_ulong( volatile Atomic_Ulong *object, unsigned long value, @@ -303,6 +379,18 @@ static inline void *_CPU_atomic_Exchange_ptr( * @retval true if the compare exchange successully. * @retval false if the compare exchange failed. */ +static inline bool _CPU_atomic_Compare_exchange_uint( + volatile Atomic_Uint *object, + unsigned int *old_value, + unsigned int new_value, + Atomic_Order order_succ, + Atomic_Order order_fail +) +{ + return atomic_compare_exchange_strong_explicit( object, old_value, + new_value, order_succ, order_fail ); +} + static inline bool _CPU_atomic_Compare_exchange_ulong( volatile Atomic_Ulong *object, unsigned long *old_value, |