[PATCH 3/4] modify the spatomic testcase to new stdatomic.h implementation

WeiY wei.a.yang at gmail.com
Sat Jun 22 13:24:41 UTC 2013


---
 testsuites/sptests/spatomic01/tasks.c |   31 ++++++++-------
 testsuites/sptests/spatomic02/tasks.c |   33 ++++++++--------
 testsuites/sptests/spatomic03/tasks.c |   42 +++++++++++---------
 testsuites/sptests/spatomic04/tasks.c |   44 +++++++++++----------
 testsuites/sptests/spatomic05/tasks.c |   42 +++++++++++---------
 testsuites/sptests/spatomic06/tasks.c |   43 +++++++++++---------
 testsuites/sptests/spatomic07/tasks.c |   69 ++++++++++++++++++---------------
 7 files changed, 164 insertions(+), 140 deletions(-)

diff --git a/testsuites/sptests/spatomic01/tasks.c b/testsuites/sptests/spatomic01/tasks.c
index c75a94d..b7bc740 100644
--- a/testsuites/sptests/spatomic01/tasks.c
+++ b/testsuites/sptests/spatomic01/tasks.c
@@ -18,18 +18,19 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, task_id, mem_bar)     \
+#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)     \
 {                                                        \
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;            \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
   unsigned int i;                                        \
-  a = _Atomic_Load_##NAME(&t, mem_bar);                  \
-  rtems_test_assert(a == t);                             \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    t = (Atomic_##TYPE)rand();                           \
+    b = (R_TYPE)rand();                                  \
+    atomic_init(&t, b);                                  \
     a = _Atomic_Load_##NAME(&t, mem_bar);                \
-    rtems_test_assert(a == t);                           \
+    rtems_test_assert(a == b);                           \
   }                                                      \
   printf("\ntask%d: _Atomic_Load_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
@@ -48,22 +49,22 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(32, Int32, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic02/tasks.c b/testsuites/sptests/spatomic02/tasks.c
index 67c2460..1e96a03 100644
--- a/testsuites/sptests/spatomic02/tasks.c
+++ b/testsuites/sptests/spatomic02/tasks.c
@@ -18,18 +18,19 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, task_id, mem_bar)    \
+#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)    \
 {                                                        \
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;            \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
   unsigned int i;                                        \
-  _Atomic_Store_##NAME(&a, t, mem_bar);                  \
-  rtems_test_assert(a == t);                             \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    t = (Atomic_##TYPE)rand();                           \
-    _Atomic_Store_##NAME(&a, t, mem_bar);                \
-    rtems_test_assert(a == t);                           \
+    b = (R_TYPE)rand();                                  \
+    _Atomic_Store_##NAME(&t, b, mem_bar);                \
+    a = _Atomic_Load_##NAME(&t, mem_bar);                \
+    rtems_test_assert(a == b);                           \
   }                                                      \
   printf("\ntask%d: _Atomic_Store_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
@@ -48,22 +49,22 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_STORE_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test release barrier */
-  ATOMIC_STORE_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_STORE_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_STORE_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic03/tasks.c b/testsuites/sptests/spatomic03/tasks.c
index 2218b1b..2d9dcc9 100644
--- a/testsuites/sptests/spatomic03/tasks.c
+++ b/testsuites/sptests/spatomic03/tasks.c
@@ -18,18 +18,22 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_FETCH_ADD_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+#define ATOMIC_FETCH_ADD_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)\
 {                                                        \
-  Atomic_##TYPE t = 0, a = 0, b = 0;                     \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
+  R_TYPE c;                                              \
   unsigned int i;                                        \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    a = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    b = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    t = a;                                               \
+    a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                \
     _Atomic_Fetch_add_##NAME(&t, b, mem_bar);            \
-    rtems_test_assert(t == (Atomic_##TYPE)(a + b));      \
+    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    rtems_test_assert(c == (R_TYPE)(a + b));             \
   }                                                      \
   printf("\ntask%d: _Atomic_Fetch_add_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
@@ -48,31 +52,31 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* test release barrier */
-  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic04/tasks.c b/testsuites/sptests/spatomic04/tasks.c
index 4600f39..a9241da 100644
--- a/testsuites/sptests/spatomic04/tasks.c
+++ b/testsuites/sptests/spatomic04/tasks.c
@@ -18,19 +18,23 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_FETCH_SUB_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+#define ATOMIC_FETCH_SUB_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)\
 {                                                        \
-  Atomic_##TYPE t = 0, a = 0, b = 0;                     \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
+  R_TYPE c;                                              \
   unsigned int i;                                        \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    a = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    b = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    t = a;                                               \
+    a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                \
     _Atomic_Fetch_sub_##NAME(&t, b, mem_bar);            \
-    rtems_test_assert(t == (Atomic_##TYPE)(a - b));      \
-  }                                                      \
+    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    rtems_test_assert(c == (R_TYPE)(a - b));             \
+  }                                                            \
   printf("\ntask%d: _Atomic_Fetch_sub_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
 
@@ -48,31 +52,31 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* test release barrier */
-  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic05/tasks.c b/testsuites/sptests/spatomic05/tasks.c
index d0df98a..3dcd991 100644
--- a/testsuites/sptests/spatomic05/tasks.c
+++ b/testsuites/sptests/spatomic05/tasks.c
@@ -18,18 +18,22 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_FETCH_AND_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+#define ATOMIC_FETCH_AND_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)\
 {                                                        \
-  Atomic_##TYPE t = 0, a = 0, b = 0;                     \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
+  R_TYPE c;                                              \
   unsigned int i;                                        \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    a = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    b = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    t = a;                                               \
+    a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                \
     _Atomic_Fetch_and_##NAME(&t, b, mem_bar);            \
-    rtems_test_assert(t == (Atomic_##TYPE)(a & b));      \
+    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    rtems_test_assert(c == (R_TYPE)(a & b));      \
   }                                                      \
   printf("\ntask%d: _Atomic_Fetch_and_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
@@ -48,31 +52,31 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* test release barrier */
-  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic06/tasks.c b/testsuites/sptests/spatomic06/tasks.c
index 753b91a..23db269 100644
--- a/testsuites/sptests/spatomic06/tasks.c
+++ b/testsuites/sptests/spatomic06/tasks.c
@@ -18,18 +18,22 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_FETCH_OR_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+#define ATOMIC_FETCH_OR_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar) \
 {                                                        \
-  Atomic_##TYPE t = 0, a = 0, b = 0;                     \
+  Atomic_##TYPE t;                                       \
+  R_TYPE a;                                              \
+  R_TYPE b;                                              \
+  R_TYPE c;                                              \
   unsigned int i;                                        \
   for (i = 0; i < TEST_REPEAT; i++){                     \
-    a = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    b = (Atomic_##TYPE)(rand() % ((Atomic_##TYPE)-1 / 2));  \
-    t = a;                                               \
+    a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                \
     _Atomic_Fetch_or_##NAME(&t, b, mem_bar);             \
-    rtems_test_assert(t == (Atomic_##TYPE)(a | b));      \
+    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    rtems_test_assert(c == (R_TYPE)(a | b));      \
   }                                                      \
   printf("\ntask%d: _Atomic_Fetch_or_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
 }
@@ -48,31 +52,32 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* test release barrier */
-  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
+
+  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic07/tasks.c b/testsuites/sptests/spatomic07/tasks.c
index ff925d0..fe05145 100644
--- a/testsuites/sptests/spatomic07/tasks.c
+++ b/testsuites/sptests/spatomic07/tasks.c
@@ -18,34 +18,39 @@
 #include <stdlib.h>
 #include <rtems/rtems/atomic.h>
 
-#define TEST_REPEAT 200000
+#define TEST_REPEAT 2000
 
-#define ATOMIC_CAS_NO_BARRIER(NAME, TYPE, task_id, mem_bar)     \
+#define ATOMIC_CAS_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)     \
 {                                                       \
-  Atomic_##TYPE a = 0, b = 0;                           \
+  Atomic_##TYPE t;                                      \
+  R_TYPE a;                                             \
+  R_TYPE b;                                             \
   unsigned int i;                                       \
   int r;                                                \
   for (i = 0; i < TEST_REPEAT; i++){                    \
-    a = rand() % (Atomic_##TYPE)-1;                     \
-    b = a;                                              \
-    r = _Atomic_Compare_exchange_##NAME(&b, a + 1, a - 1, mem_bar);                 \
-    if(r != 0){                                                                     \
+    a = rand() % (R_TYPE)-1;                            \
+    _Atomic_Store_##NAME(&t, a, mem_bar);               \
+    b = a + 1;                                                           \
+    r = _Atomic_Compare_exchange_##NAME(&t, &b, a - 1, mem_bar);         \
+    if(r != 0){                                                          \
       printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)task_id); \
-      rtems_test_exit( 0 );                                                         \
-    }                                                                               \
-    b = a;                                                                          \
-    r = _Atomic_Compare_exchange_##NAME(&b, a, a - 1, mem_bar);                     \
-    if((r == 0) ||((r != 0) && ((a - 1) != b))){                                    \
+      rtems_test_exit( 0 );                                              \
+    }                                                                    \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                                \
+    r = _Atomic_Compare_exchange_##NAME(&t, &a, a - 1, mem_bar);         \
+    b = _Atomic_Load_##NAME(&t, mem_bar);                                \
+    if((r == 0) ||((r != 0) && ((a - 1) != b))){                         \
       printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)task_id); \
-      rtems_test_exit( 0 );                                                         \
-    }                                                                               \
-    b = a;                                                                          \
-    r = _Atomic_Compare_exchange_##NAME(&b, a + 1, a, mem_bar);                     \
-    if(r != 0){                                                                     \
+      rtems_test_exit( 0 );                                              \
+    }                                                                    \
+    _Atomic_Store_##NAME(&t, a, mem_bar);                                \
+    b = a + 1;                                                           \
+    r = _Atomic_Compare_exchange_##NAME(&t, &b, a, mem_bar);             \
+    if(r != 0){                                                          \
       printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)task_id); \
-      rtems_test_exit( 0 );                                                         \
-    }                                                                               \
-  }                                                                                 \
+      rtems_test_exit( 0 );                                              \
+    }                                                                    \
+  }                                                                      \
   printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": SUCCESS\n", (unsigned int)task_id);    \
 }
 
@@ -63,31 +68,31 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_CAS_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELAXED_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELAXED_BARRIER);
 
   /* test acquire barrier */
-  ATOMIC_CAS_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_ACQUIRE_BARRIER);
 
   /* test release barrier */
-  ATOMIC_CAS_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(int, Int, unsigned int, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(long, Long, unsigned long, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(ptr, Pointer, uintptr_t, argument, ATOMIC_RELEASE_BARRIER);
 
-  ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+  ATOMIC_CAS_NO_BARRIER(32, Int32, uint32_t, argument, ATOMIC_RELEASE_BARRIER);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
-- 
1.7.9.5




More information about the devel mailing list