[rtems commit] score: Use uintptr_t for atomic pointer operations

Sebastian Huber sebh at rtems.org
Sat Sep 26 19:25:58 UTC 2015


Module:    rtems
Branch:    master
Commit:    8d296cd54e51d2fe1f6bf5344cca70c822b04568
Changeset: http://git.rtems.org/rtems/commit/?id=8d296cd54e51d2fe1f6bf5344cca70c822b04568

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Sep 26 13:03:16 2015 +0200

score: Use uintptr_t for atomic pointer operations

Do not obfuscate the standard API.

---

 cpukit/score/include/rtems/score/atomic.h       |  40 +++---
 cpukit/score/include/rtems/score/cpustdatomic.h | 100 ++++++++-------
 testsuites/smptests/smpatomic01/init.c          |   1 -
 testsuites/smptests/smpatomic01/smpatomic01.doc |  15 ---
 testsuites/sptests/spatomic01/init.c            | 155 +++++++++++++++++-------
 testsuites/sptests/spatomic01/spatomic01.doc    |  13 +-
 6 files changed, 189 insertions(+), 135 deletions(-)

diff --git a/cpukit/score/include/rtems/score/atomic.h b/cpukit/score/include/rtems/score/atomic.h
index 0cf3e99..5269269 100644
--- a/cpukit/score/include/rtems/score/atomic.h
+++ b/cpukit/score/include/rtems/score/atomic.h
@@ -38,7 +38,7 @@ typedef CPU_atomic_Uint Atomic_Uint;
 
 typedef CPU_atomic_Ulong Atomic_Ulong;
 
-typedef CPU_atomic_Pointer Atomic_Pointer;
+typedef CPU_atomic_Uintptr Atomic_Uintptr;
 
 typedef CPU_atomic_Flag Atomic_Flag;
 
@@ -58,7 +58,7 @@ typedef CPU_atomic_Order Atomic_Order;
 
 #define ATOMIC_INITIALIZER_ULONG( value ) CPU_ATOMIC_INITIALIZER_ULONG( value )
 
-#define ATOMIC_INITIALIZER_PTR( value ) CPU_ATOMIC_INITIALIZER_PTR( value )
+#define ATOMIC_INITIALIZER_UINTPTR( value ) CPU_ATOMIC_INITIALIZER_UINTPTR( value )
 
 #define ATOMIC_INITIALIZER_FLAG CPU_ATOMIC_INITIALIZER_FLAG
 
@@ -70,8 +70,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Init_ulong( obj, desired ) \
   _CPU_atomic_Init_ulong( obj, desired )
 
-#define _Atomic_Init_ptr( obj, desired ) \
-  _CPU_atomic_Init_ptr( obj, desired )
+#define _Atomic_Init_uintptr( obj, desired ) \
+  _CPU_atomic_Init_uintptr( obj, desired )
 
 #define _Atomic_Load_uint( obj, order ) \
   _CPU_atomic_Load_uint( obj, order )
@@ -79,8 +79,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Load_ulong( obj, order ) \
   _CPU_atomic_Load_ulong( obj, order )
 
-#define _Atomic_Load_ptr( obj, order ) \
-  _CPU_atomic_Load_ptr( obj, order )
+#define _Atomic_Load_uintptr( obj, order ) \
+  _CPU_atomic_Load_uintptr( obj, order )
 
 #define _Atomic_Store_uint( obj, desr, order ) \
   _CPU_atomic_Store_uint( obj, desr, order )
@@ -88,8 +88,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Store_ulong( obj, desr, order ) \
   _CPU_atomic_Store_ulong( obj, desr, order )
 
-#define _Atomic_Store_ptr( obj, desr, order ) \
-  _CPU_atomic_Store_ptr( obj, desr, order )
+#define _Atomic_Store_uintptr( obj, desr, order ) \
+  _CPU_atomic_Store_uintptr( obj, desr, order )
 
 #define _Atomic_Fetch_add_uint( obj, arg, order ) \
   _CPU_atomic_Fetch_add_uint( obj, arg, order )
@@ -97,8 +97,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Fetch_add_ulong( obj, arg, order ) \
   _CPU_atomic_Fetch_add_ulong( obj, arg, order )
 
-#define _Atomic_Fetch_add_ptr( obj, arg, order ) \
-  _CPU_atomic_Fetch_add_ptr( obj, arg, order )
+#define _Atomic_Fetch_add_uintptr( obj, arg, order ) \
+  _CPU_atomic_Fetch_add_uintptr( obj, arg, order )
 
 #define _Atomic_Fetch_sub_uint( obj, arg, order ) \
   _CPU_atomic_Fetch_sub_uint( obj, arg, order )
@@ -106,8 +106,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Fetch_sub_ulong( obj, arg, order ) \
   _CPU_atomic_Fetch_sub_ulong( obj, arg, order )
 
-#define _Atomic_Fetch_sub_ptr( obj, arg, order ) \
-  _CPU_atomic_Fetch_sub_ptr( obj, arg, order )
+#define _Atomic_Fetch_sub_uintptr( obj, arg, order ) \
+  _CPU_atomic_Fetch_sub_uintptr( obj, arg, order )
 
 #define _Atomic_Fetch_or_uint( obj, arg, order ) \
   _CPU_atomic_Fetch_or_uint( obj, arg, order )
@@ -115,8 +115,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Fetch_or_ulong( obj, arg, order ) \
   _CPU_atomic_Fetch_or_ulong( obj, arg, order )
 
-#define _Atomic_Fetch_or_ptr( obj, arg, order ) \
-  _CPU_atomic_Fetch_or_ptr( obj, arg, order )
+#define _Atomic_Fetch_or_uintptr( obj, arg, order ) \
+  _CPU_atomic_Fetch_or_uintptr( obj, arg, order )
 
 #define _Atomic_Fetch_and_uint( obj, arg, order ) \
   _CPU_atomic_Fetch_and_uint( obj, arg, order )
@@ -124,8 +124,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Fetch_and_ulong( obj, arg, order ) \
   _CPU_atomic_Fetch_and_ulong( obj, arg, order )
 
-#define _Atomic_Fetch_and_ptr( obj, arg, order ) \
-  _CPU_atomic_Fetch_and_ptr( obj, arg, order )
+#define _Atomic_Fetch_and_uintptr( obj, arg, order ) \
+  _CPU_atomic_Fetch_and_uintptr( obj, arg, order )
 
 #define _Atomic_Exchange_uint( obj, desr, order ) \
   _CPU_atomic_Exchange_uint( obj, desr, order )
@@ -133,8 +133,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Exchange_ulong( obj, desr, order ) \
   _CPU_atomic_Exchange_ulong( obj, desr, order )
 
-#define _Atomic_Exchange_ptr( obj, desr, order ) \
-  _CPU_atomic_Exchange_ptr( obj, desr, order )
+#define _Atomic_Exchange_uintptr( obj, desr, order ) \
+  _CPU_atomic_Exchange_uintptr( obj, desr, order )
 
 #define _Atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
   _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail )
@@ -142,8 +142,8 @@ typedef CPU_atomic_Order Atomic_Order;
 #define _Atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
   _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail )
 
-#define _Atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
-  _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail )
+#define _Atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) \
+  _CPU_atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail )
 
 #define _Atomic_Flag_clear( obj, order ) \
   _CPU_atomic_Flag_clear( obj, order )
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h
index c66dd7e..fb7ba2d 100644
--- a/cpukit/score/include/rtems/score/cpustdatomic.h
+++ b/cpukit/score/include/rtems/score/cpustdatomic.h
@@ -45,7 +45,7 @@ typedef std::atomic_uint CPU_atomic_Uint;
 
 typedef std::atomic_ulong CPU_atomic_Ulong;
 
-typedef std::atomic_uintptr_t CPU_atomic_Pointer;
+typedef std::atomic_uintptr_t CPU_atomic_Uintptr;
 
 typedef std::atomic_flag CPU_atomic_Flag;
 
@@ -65,8 +65,7 @@ typedef std::memory_order CPU_atomic_Order;
 
 #define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value )
 
-#define CPU_ATOMIC_INITIALIZER_PTR( value ) \
-  ATOMIC_VAR_INIT( (uintptr_t) (value) )
+#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value )
 
 #define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
 
@@ -76,7 +75,7 @@ typedef atomic_uint CPU_atomic_Uint;
 
 typedef atomic_ulong CPU_atomic_Ulong;
 
-typedef atomic_uintptr_t CPU_atomic_Pointer;
+typedef atomic_uintptr_t CPU_atomic_Uintptr;
 
 typedef atomic_flag CPU_atomic_Flag;
 
@@ -96,8 +95,7 @@ typedef memory_order CPU_atomic_Order;
 
 #define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value )
 
-#define CPU_ATOMIC_INITIALIZER_PTR( value ) \
-  ATOMIC_VAR_INIT( (uintptr_t) (value) )
+#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value )
 
 #define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
 
@@ -107,7 +105,7 @@ typedef unsigned int CPU_atomic_Uint;
 
 typedef unsigned long CPU_atomic_Ulong;
 
-typedef uintptr_t CPU_atomic_Pointer;
+typedef uintptr_t CPU_atomic_Uintptr;
 
 typedef bool CPU_atomic_Flag;
 
@@ -127,7 +125,7 @@ typedef int CPU_atomic_Order;
 
 #define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value )
 
-#define CPU_ATOMIC_INITIALIZER_PTR( value ) ( (uintptr_t) (value) )
+#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ( value )
 
 #define CPU_ATOMIC_INITIALIZER_FLAG false
 
@@ -167,14 +165,14 @@ static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long
 #endif
 }
 
-static inline void _CPU_atomic_Init_ptr( CPU_atomic_Pointer *obj, void *desired )
+static inline void _CPU_atomic_Init_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  obj->store( (uintptr_t) desired );
+  obj->store( desired );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  atomic_init( obj, (uintptr_t) desired );
+  atomic_init( obj, desired );
 #else
-  *obj = (uintptr_t) desired;
+  *obj = desired;
 #endif
 }
 
@@ -212,12 +210,12 @@ static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj,
 #endif
 }
 
-static inline void *_CPU_atomic_Load_ptr( const CPU_atomic_Pointer *obj, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Load_uintptr( const CPU_atomic_Uintptr *obj, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->load( order );
+  return obj->load( order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_load_explicit( obj, order );
+  return atomic_load_explicit( obj, order );
 #else
   uintptr_t val;
 
@@ -225,7 +223,7 @@ static inline void *_CPU_atomic_Load_ptr( const CPU_atomic_Pointer *obj, CPU_ato
   val = *obj;
   RTEMS_COMPILER_MEMORY_BARRIER();
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -255,16 +253,16 @@ static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long
 #endif
 }
 
-static inline void _CPU_atomic_Store_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
+static inline void _CPU_atomic_Store_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  obj->store( (uintptr_t) desired );
+  obj->store( desired );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  atomic_store_explicit( obj, (uintptr_t) desired, order );
+  atomic_store_explicit( obj, desired, order );
 #else
   (void) order;
   RTEMS_COMPILER_MEMORY_BARRIER();
-  *obj = (uintptr_t) desired;
+  *obj = desired;
 #endif
 }
 
@@ -308,12 +306,12 @@ static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj,
 #endif
 }
 
-static inline void *_CPU_atomic_Fetch_add_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Fetch_add_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->fetch_add( (uintptr_t) arg, order );
+  return obj->fetch_add( arg, order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_fetch_add_explicit( obj, (uintptr_t) arg, order );
+  return atomic_fetch_add_explicit( obj, arg, order );
 #else
   uintptr_t val;
   ISR_Level level;
@@ -321,10 +319,10 @@ static inline void *_CPU_atomic_Fetch_add_ptr( CPU_atomic_Pointer *obj, void *ar
   (void) order;
   _ISR_Disable( level );
   val = *obj;
-  *obj = val + (uintptr_t) arg;
+  *obj = val + arg;
   _ISR_Enable( level );
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -368,12 +366,12 @@ static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj,
 #endif
 }
 
-static inline void *_CPU_atomic_Fetch_sub_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Fetch_sub_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->fetch_sub( (uintptr_t) arg, order );
+  return obj->fetch_sub( arg, order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_fetch_sub_explicit( obj, (uintptr_t) arg, order );
+  return atomic_fetch_sub_explicit( obj, arg, order );
 #else
   uintptr_t val;
   ISR_Level level;
@@ -381,10 +379,10 @@ static inline void *_CPU_atomic_Fetch_sub_ptr( CPU_atomic_Pointer *obj, void *ar
   (void) order;
   _ISR_Disable( level );
   val = *obj;
-  *obj = val - (uintptr_t) arg;
+  *obj = val - arg;
   _ISR_Enable( level );
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -428,12 +426,12 @@ static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, u
 #endif
 }
 
-static inline void *_CPU_atomic_Fetch_or_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Fetch_or_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->fetch_or( (uintptr_t) arg, order );
+  return obj->fetch_or( arg, order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_fetch_or_explicit( obj, (uintptr_t) arg, order );
+  return atomic_fetch_or_explicit( obj, arg, order );
 #else
   uintptr_t val;
   ISR_Level level;
@@ -441,10 +439,10 @@ static inline void *_CPU_atomic_Fetch_or_ptr( CPU_atomic_Pointer *obj, void *arg
   (void) order;
   _ISR_Disable( level );
   val = *obj;
-  *obj = val | (uintptr_t) arg;
+  *obj = val | arg;
   _ISR_Enable( level );
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -488,12 +486,12 @@ static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj,
 #endif
 }
 
-static inline void *_CPU_atomic_Fetch_and_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Fetch_and_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->fetch_and( (uintptr_t) arg, order );
+  return obj->fetch_and( arg, order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_fetch_and_explicit( obj, (uintptr_t) arg, order );
+  return atomic_fetch_and_explicit( obj, arg, order );
 #else
   uintptr_t val;
   ISR_Level level;
@@ -501,10 +499,10 @@ static inline void *_CPU_atomic_Fetch_and_ptr( CPU_atomic_Pointer *obj, void *ar
   (void) order;
   _ISR_Disable( level );
   val = *obj;
-  *obj = val & (uintptr_t) arg;
+  *obj = val & arg;
   _ISR_Enable( level );
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -548,12 +546,12 @@ static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, u
 #endif
 }
 
-static inline void *_CPU_atomic_Exchange_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
+static inline uintptr_t _CPU_atomic_Exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return (void *) obj->exchange( (uintptr_t) desired, order );
+  return obj->exchange( desired, order );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return (void *) atomic_exchange_explicit( obj, (uintptr_t) desired, order );
+  return atomic_exchange_explicit( obj, desired, order );
 #else
   uintptr_t val;
   ISR_Level level;
@@ -561,10 +559,10 @@ static inline void *_CPU_atomic_Exchange_ptr( CPU_atomic_Pointer *obj, void *des
   (void) order;
   _ISR_Disable( level );
   val = *obj;
-  *obj = (uintptr_t) desired;
+  *obj = desired;
   _ISR_Enable( level );
 
-  return (void *) val;
+  return val;
 #endif
 }
 
@@ -622,12 +620,12 @@ static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, un
 #endif
 }
 
-static inline bool _CPU_atomic_Compare_exchange_ptr( CPU_atomic_Pointer *obj, void **expected, void *desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
+static inline bool _CPU_atomic_Compare_exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
 {
 #if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
-  return obj->compare_exchange_strong( *(uintptr_t *) expected, (uintptr_t) desired, succ, fail );
+  return obj->compare_exchange_strong( *expected, desired, succ, fail );
 #elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
-  return atomic_compare_exchange_strong_explicit( obj, (uintptr_t *) expected, (uintptr_t) desired, succ, fail );
+  return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail );
 #else
   bool success;
   ISR_Level level;
@@ -637,11 +635,11 @@ static inline bool _CPU_atomic_Compare_exchange_ptr( CPU_atomic_Pointer *obj, vo
   (void) fail;
   _ISR_Disable( level );
   actual = *obj;
-  success = ( actual == (uintptr_t) *expected );
+  success = ( actual == *expected );
   if ( success ) {
-    *obj = (uintptr_t) desired;
+    *obj = desired;
   } else {
-    *expected = (void *) actual;
+    *expected = actual;
   }
   _ISR_Enable( level );
 
diff --git a/testsuites/smptests/smpatomic01/init.c b/testsuites/smptests/smpatomic01/init.c
index 72ccdf2..5d0f665 100644
--- a/testsuites/smptests/smpatomic01/init.c
+++ b/testsuites/smptests/smpatomic01/init.c
@@ -36,7 +36,6 @@ const char rtems_test_name[] = "SMPATOMIC 1";
 
 typedef struct {
   rtems_test_parallel_context base;
-  Atomic_Uint atomic_int_value;
   Atomic_Ulong atomic_value;
   unsigned long per_worker_value[CPU_COUNT];
   unsigned long normal_value;
diff --git a/testsuites/smptests/smpatomic01/smpatomic01.doc b/testsuites/smptests/smpatomic01/smpatomic01.doc
index e0310e0..0b32da9 100644
--- a/testsuites/smptests/smpatomic01/smpatomic01.doc
+++ b/testsuites/smptests/smpatomic01/smpatomic01.doc
@@ -4,32 +4,17 @@ test set name: smpatomic01
 
 directives:
 
-  - ATOMIC_INITIALIZER_FLAG
-  - ATOMIC_INITIALIZER_PTR()
-  - ATOMIC_INITIALIZER_UINT()
-  - ATOMIC_INITIALIZER_ULONG()
-  - _Atomic_Compare_exchange_uint()
   - _Atomic_Compare_exchange_ulong()
-  - _Atomic_Exchange_uint()
   - _Atomic_Exchange_ulong()
   - _Atomic_Fence()
-  - _Atomic_Fetch_add_uint()
   - _Atomic_Fetch_add_ulong()
-  - _Atomic_Fetch_and_uint()
   - _Atomic_Fetch_and_ulong()
-  - _Atomic_Fetch_or_uint()
   - _Atomic_Fetch_or_ulong()
-  - _Atomic_Fetch_sub_uint()
   - _Atomic_Fetch_sub_ulong()
   - _Atomic_Flag_clear()
   - _Atomic_Flag_test_and_set()
-  - _Atomic_Init_ptr()
-  - _Atomic_Init_uint()
   - _Atomic_Init_ulong()
-  - _Atomic_Load_ptr()
-  - _Atomic_Load_uint()
   - _Atomic_Load_ulong()
-  - _Atomic_Store_uint()
   - _Atomic_Store_ulong()
 
 concepts:
diff --git a/testsuites/sptests/spatomic01/init.c b/testsuites/sptests/spatomic01/init.c
index b90ffd0..b5fa6c4 100644
--- a/testsuites/sptests/spatomic01/init.c
+++ b/testsuites/sptests/spatomic01/init.c
@@ -27,8 +27,9 @@
 const char rtems_test_name[] = "SPATOMIC 1";
 
 typedef struct {
-  Atomic_Uint atomic_int_value;
-  Atomic_Ulong atomic_value;
+  Atomic_Uint uint_atomic;
+  Atomic_Uintptr uintptr_atomic;
+  Atomic_Ulong ulong_atomic;
 } test_context;
 
 static test_context test_instance;
@@ -43,19 +44,20 @@ static void test_static_and_dynamic_initialization(void)
 
   static Atomic_Uint static_uint   = ATOMIC_INITIALIZER_UINT(UINT_CONSTANT);
   static Atomic_Ulong static_ulong = ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
-  static Atomic_Pointer static_ptr = ATOMIC_INITIALIZER_PTR(&static_ptr);
+  static Atomic_Uintptr static_uintptr =
+    ATOMIC_INITIALIZER_UINTPTR((uintptr_t) &static_uintptr);
   static Atomic_Flag static_flag  = ATOMIC_INITIALIZER_FLAG;
 
   Atomic_Uint stack_uint;
   Atomic_Ulong stack_ulong;
-  Atomic_Pointer stack_ptr;
+  Atomic_Uintptr stack_uintptr;
   Atomic_Flag stack_flag;
 
   puts("=== static and dynamic initialization test case ===");
 
   _Atomic_Init_uint(&stack_uint, UINT_CONSTANT);
   _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
-  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
+  _Atomic_Init_uintptr(&stack_uintptr, (uintptr_t) &static_uintptr);
   _Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);
 
   rtems_test_assert(
@@ -65,7 +67,7 @@ static void test_static_and_dynamic_initialization(void)
     memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
   );
   rtems_test_assert(
-    memcmp(&stack_ptr, &static_ptr, sizeof(stack_ptr)) == 0
+    memcmp(&stack_uintptr, &static_uintptr, sizeof(stack_uintptr)) == 0
   );
   rtems_test_assert(
     memcmp(&stack_flag, &static_flag, sizeof(stack_flag)) == 0
@@ -78,7 +80,8 @@ static void test_static_and_dynamic_initialization(void)
     _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
   );
   rtems_test_assert(
-    _Atomic_Load_ptr(&stack_ptr, ATOMIC_ORDER_RELAXED) == &static_ptr
+    _Atomic_Load_uintptr(&stack_uintptr, ATOMIC_ORDER_RELAXED)
+      == (uintptr_t) &static_uintptr
   );
   rtems_test_assert(
     !_Atomic_Flag_test_and_set(&stack_flag, ATOMIC_ORDER_RELAXED)
@@ -91,19 +94,26 @@ static void test_simple_atomic_add_body(test_context *ctx)
 {
   unsigned int ia = 8, ib = 4;
   unsigned int ic;
+  uintptr_t pa = 42, pb = 24;
+  uintptr_t pc;
   unsigned long a = 2, b = 1;
   unsigned long c;
 
   puts("=== atomic simple add test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_add_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_add_uint(&ctx->uint_atomic, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(ic == (ia + ib));
 
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_add_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, pa, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_add_uintptr(&ctx->uintptr_atomic, pb, ATOMIC_ORDER_RELAXED);
+  pc = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == (pa + pb));
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_add_ulong(&ctx->ulong_atomic, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(c == (a + b));
 }
 
@@ -111,19 +121,26 @@ static void test_simple_atomic_sub_body(test_context *ctx)
 {
   unsigned int ia = 8, ib = 4;
   unsigned int ic;
+  uintptr_t pa = 42, pb = 24;
+  uintptr_t pc;
   unsigned long a = 2, b = 1;
   unsigned long c;
 
   puts("=== atomic simple sub test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_sub_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_sub_uint(&ctx->uint_atomic, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(ic == (ia - ib));
 
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_sub_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, pa, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_sub_uintptr(&ctx->uintptr_atomic, pb, ATOMIC_ORDER_RELAXED);
+  pc = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == (pa - pb));
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_sub_ulong(&ctx->ulong_atomic, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(c == (a - b));
 }
 
@@ -131,19 +148,26 @@ static void test_simple_atomic_or_body(test_context *ctx)
 {
   unsigned int ia = 8, ib = 4;
   unsigned int ic;
+  uintptr_t pa = 42, pb = 24;
+  uintptr_t pc;
   unsigned long a = 2, b = 1;
   unsigned long c;
 
   puts("=== atomic simple or test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_or_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_or_uint(&ctx->uint_atomic, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(ic == (ia | ib));
 
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_or_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, pa, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_or_uintptr(&ctx->uintptr_atomic, pb, ATOMIC_ORDER_RELAXED);
+  pc = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == (pa | pb));
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_or_ulong(&ctx->ulong_atomic, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(c == (a | b));
 }
 
@@ -151,19 +175,26 @@ static void test_simple_atomic_and_body(test_context *ctx)
 {
   unsigned int ia = 8, ib = 4;
   unsigned int ic;
+  uintptr_t pa = 42, pb = 24;
+  uintptr_t pc;
   unsigned long a = 2, b = 1;
   unsigned long c;
 
   puts("=== atomic simple and test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_and_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_and_uint(&ctx->uint_atomic, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(ic == (ia & ib));
 
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_and_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, pa, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_and_uintptr(&ctx->uintptr_atomic, pb, ATOMIC_ORDER_RELAXED);
+  pc = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == (pa & pb));
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_and_ulong(&ctx->ulong_atomic, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(c == (a & b));
 }
 
@@ -171,19 +202,29 @@ static void test_simple_atomic_exchange_body(test_context *ctx)
 {
   unsigned int ia = 8, ib = 4;
   unsigned int ic;
+  uintptr_t pa = 42, pb = 24;
+  uintptr_t pc;
   unsigned long a = 2, b = 1;
   unsigned long c;
 
   puts("=== atomic simple exchange test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Exchange_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, ia, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Exchange_uint(&ctx->uint_atomic, ib, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == ia);
+  ic = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(ic == ib);
 
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Exchange_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, pa, ATOMIC_ORDER_RELAXED);
+  pc = _Atomic_Exchange_uintptr(&ctx->uintptr_atomic, pb, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == pa);
+  pc = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(pc == pb);
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, a, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Exchange_ulong(&ctx->ulong_atomic, b, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == a);
+  c = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(c == b);
 }
 
@@ -191,16 +232,18 @@ static void test_simple_atomic_compare_exchange_body(test_context *ctx)
 {
   unsigned int ei;
   unsigned int vi;
+  uintptr_t ep;
+  uintptr_t vp;
   unsigned long el;
   unsigned long vl;
   bool success;
 
   puts("=== atomic simple compare exchange test case ===");
 
-  _Atomic_Store_uint(&ctx->atomic_int_value, 1, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uint(&ctx->uint_atomic, 1, ATOMIC_ORDER_RELAXED);
   ei = 2;
   success = _Atomic_Compare_exchange_uint(
-    &ctx->atomic_int_value,
+    &ctx->uint_atomic,
     &ei,
     3,
     ATOMIC_ORDER_RELAXED,
@@ -209,20 +252,42 @@ static void test_simple_atomic_compare_exchange_body(test_context *ctx)
   rtems_test_assert(!success);
   rtems_test_assert(ei == 1);
   success = _Atomic_Compare_exchange_uint(
-    &ctx->atomic_int_value,
+    &ctx->uint_atomic,
     &ei,
     3,
     ATOMIC_ORDER_RELAXED,
     ATOMIC_ORDER_RELAXED
   );
   rtems_test_assert(success);
-  vi = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  vi = _Atomic_Load_uint(&ctx->uint_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(vi == 3);
 
-  _Atomic_Store_ulong(&ctx->atomic_value, 10, ATOMIC_ORDER_RELAXED);
+  _Atomic_Store_uintptr(&ctx->uintptr_atomic, 111, ATOMIC_ORDER_RELAXED);
+  ep = 211;
+  success = _Atomic_Compare_exchange_uintptr(
+    &ctx->uintptr_atomic,
+    &ep,
+    311,
+    ATOMIC_ORDER_RELAXED,
+    ATOMIC_ORDER_RELAXED
+  );
+  rtems_test_assert(!success);
+  rtems_test_assert(ep == 111);
+  success = _Atomic_Compare_exchange_uintptr(
+    &ctx->uintptr_atomic,
+    &ep,
+    311,
+    ATOMIC_ORDER_RELAXED,
+    ATOMIC_ORDER_RELAXED
+  );
+  rtems_test_assert(success);
+  vp = _Atomic_Load_uintptr(&ctx->uintptr_atomic, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(vp == 311);
+
+  _Atomic_Store_ulong(&ctx->ulong_atomic, 10, ATOMIC_ORDER_RELAXED);
   el = 11;
   success = _Atomic_Compare_exchange_ulong(
-    &ctx->atomic_value,
+    &ctx->ulong_atomic,
     &el,
     12,
     ATOMIC_ORDER_RELAXED,
@@ -231,14 +296,14 @@ static void test_simple_atomic_compare_exchange_body(test_context *ctx)
   rtems_test_assert(!success);
   rtems_test_assert(el == 10);
   success = _Atomic_Compare_exchange_ulong(
-    &ctx->atomic_value,
+    &ctx->ulong_atomic,
     &el,
     12,
     ATOMIC_ORDER_RELAXED,
     ATOMIC_ORDER_RELAXED
   );
   rtems_test_assert(success);
-  vl = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  vl = _Atomic_Load_ulong(&ctx->ulong_atomic, ATOMIC_ORDER_RELAXED);
   rtems_test_assert(vl == 12);
 }
 
diff --git a/testsuites/sptests/spatomic01/spatomic01.doc b/testsuites/sptests/spatomic01/spatomic01.doc
index 85fae09..f7ac0d3 100644
--- a/testsuites/sptests/spatomic01/spatomic01.doc
+++ b/testsuites/sptests/spatomic01/spatomic01.doc
@@ -5,31 +5,38 @@ test set name: spatomic01
 directives:
 
   - ATOMIC_INITIALIZER_FLAG
-  - ATOMIC_INITIALIZER_PTR()
+  - ATOMIC_INITIALIZER_UINTPTR()
   - ATOMIC_INITIALIZER_UINT()
   - ATOMIC_INITIALIZER_ULONG()
   - _Atomic_Compare_exchange_uint()
+  - _Atomic_Compare_exchange_uintptr()
   - _Atomic_Compare_exchange_ulong()
   - _Atomic_Exchange_uint()
+  - _Atomic_Exchange_uintptr()
   - _Atomic_Exchange_ulong()
   - _Atomic_Fence()
   - _Atomic_Fetch_add_uint()
+  - _Atomic_Fetch_add_uintptr()
   - _Atomic_Fetch_add_ulong()
   - _Atomic_Fetch_and_uint()
+  - _Atomic_Fetch_and_uintptr()
   - _Atomic_Fetch_and_ulong()
   - _Atomic_Fetch_or_uint()
+  - _Atomic_Fetch_or_uintptr()
   - _Atomic_Fetch_or_ulong()
   - _Atomic_Fetch_sub_uint()
+  - _Atomic_Fetch_sub_uintptr()
   - _Atomic_Fetch_sub_ulong()
   - _Atomic_Flag_clear()
   - _Atomic_Flag_test_and_set()
-  - _Atomic_Init_ptr()
   - _Atomic_Init_uint()
+  - _Atomic_Init_uintptr()
   - _Atomic_Init_ulong()
-  - _Atomic_Load_ptr()
   - _Atomic_Load_uint()
+  - _Atomic_Load_uintptr()
   - _Atomic_Load_ulong()
   - _Atomic_Store_uint()
+  - _Atomic_Store_uintptr()
   - _Atomic_Store_ulong()
 
 concepts:




More information about the vc mailing list