[PATCH 1/2] correct memory model in smpatomic test case

WeiY wei.a.yang at gmail.com
Sun Aug 4 18:21:03 UTC 2013


---
 testsuites/smptests/smpatomic01/tasks.c |    2 +-
 testsuites/smptests/smpatomic02/tasks.c |    2 +-
 testsuites/smptests/smpatomic03/tasks.c |    4 ++--
 testsuites/smptests/smpatomic04/tasks.c |    4 ++--
 testsuites/smptests/smpatomic05/tasks.c |    4 ++--
 testsuites/smptests/smpatomic06/tasks.c |    4 ++--
 testsuites/smptests/smpatomic07/tasks.c |    8 ++++----
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/testsuites/smptests/smpatomic01/tasks.c b/testsuites/smptests/smpatomic01/tasks.c
index 65ad81b..2fe03ea 100644
--- a/testsuites/smptests/smpatomic01/tasks.c
+++ b/testsuites/smptests/smpatomic01/tasks.c
@@ -29,7 +29,7 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     b = (R_TYPE)rand();                                  \
     atomic_init(&t, b);                                  \
-    a = _Atomic_Load_##NAME(&t, mem_bar);                \
+    a = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(a == b);                           \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Load_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic02/tasks.c b/testsuites/smptests/smpatomic02/tasks.c
index 1017bef..22de08c 100644
--- a/testsuites/smptests/smpatomic02/tasks.c
+++ b/testsuites/smptests/smpatomic02/tasks.c
@@ -29,7 +29,7 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     b = (R_TYPE)rand();                                  \
     _Atomic_Store_##NAME(&t, b, mem_bar);                \
-    a = _Atomic_Load_##NAME(&t, mem_bar);                \
+    a = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(a == b);                           \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Store_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic03/tasks.c b/testsuites/smptests/smpatomic03/tasks.c
index b74bd9d..2c45a00 100644
--- a/testsuites/smptests/smpatomic03/tasks.c
+++ b/testsuites/smptests/smpatomic03/tasks.c
@@ -30,9 +30,9 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
     b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);   \
     _Atomic_Fetch_add_##NAME(&t, b, mem_bar);            \
-    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    c = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(c == (R_TYPE)(a + b));             \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Fetch_add_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic04/tasks.c b/testsuites/smptests/smpatomic04/tasks.c
index 54f0661..3630eb2 100644
--- a/testsuites/smptests/smpatomic04/tasks.c
+++ b/testsuites/smptests/smpatomic04/tasks.c
@@ -30,9 +30,9 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
     b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);   \
     _Atomic_Fetch_sub_##NAME(&t, b, mem_bar);            \
-    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    c = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(c == (R_TYPE)(a - b));             \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Fetch_sub_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic05/tasks.c b/testsuites/smptests/smpatomic05/tasks.c
index 57a4f8c..5e7da77 100644
--- a/testsuites/smptests/smpatomic05/tasks.c
+++ b/testsuites/smptests/smpatomic05/tasks.c
@@ -30,9 +30,9 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
     b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);   \
     _Atomic_Fetch_and_##NAME(&t, b, mem_bar);            \
-    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    c = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(c == (R_TYPE)(a & b));             \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Fetch_and_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic06/tasks.c b/testsuites/smptests/smpatomic06/tasks.c
index a28cffb..772d745 100644
--- a/testsuites/smptests/smpatomic06/tasks.c
+++ b/testsuites/smptests/smpatomic06/tasks.c
@@ -30,9 +30,9 @@
   for (i = 0; i < TEST_REPEAT; i++){                     \
     a = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
     b = (R_TYPE)(rand() % ((R_TYPE)-1 / 2));             \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);   \
     _Atomic_Fetch_or_##NAME(&t, b, mem_bar);             \
-    c = _Atomic_Load_##NAME(&t, mem_bar);                \
+    c = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);   \
     rtems_test_assert(c == (R_TYPE)(a | b));             \
   }                                                      \
   locked_printf("\nCPU%d Atomic_Fetch_or_" #NAME ": SUCCESS\n", cpuid); \
diff --git a/testsuites/smptests/smpatomic07/tasks.c b/testsuites/smptests/smpatomic07/tasks.c
index 308498a..ab1b51c 100644
--- a/testsuites/smptests/smpatomic07/tasks.c
+++ b/testsuites/smptests/smpatomic07/tasks.c
@@ -29,21 +29,21 @@
   int r;                                                \
   for (i = 0; i < TEST_REPEAT; i++){                    \
     a = rand() % (R_TYPE)-1;                            \
-    _Atomic_Store_##NAME(&t, a, mem_bar);               \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);  \
     b = a + 1;                                                           \
     r = _Atomic_Compare_exchange_##NAME(&t, &b, a - 1, mem_bar, memory_order_relaxed);\
     if(r != 0){                                                          \
       locked_printf("\ntask%d: Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)cpuid); \
       rtems_test_exit( 0 );                                              \
     }                                                                    \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);                   \
     r = _Atomic_Compare_exchange_##NAME(&t, &a, a - 1, mem_bar, memory_order_relaxed);\
-    b = _Atomic_Load_##NAME(&t, mem_bar);                                \
+    b = _Atomic_Load_##NAME(&t, ATOMIC_ORDER_ACQUIRE);                   \
     if((r == 0) ||((r != 0) && ((a - 1) != b))){                         \
       locked_printf("\ntask%d: Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)cpuid); \
       rtems_test_exit( 0 );                                              \
     }                                                                    \
-    _Atomic_Store_##NAME(&t, a, mem_bar);                                \
+    _Atomic_Store_##NAME(&t, a, ATOMIC_ORDER_RELEASE);                   \
     b = a + 1;                                                           \
     r = _Atomic_Compare_exchange_##NAME(&t, &b, a, mem_bar, memory_order_relaxed); \
     if(r != 0){                                                          \
-- 
1.7.9.5




More information about the devel mailing list