summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeiY <wei.a.yang@gmail.com>2013-01-25 23:59:49 +0800
committerGedare Bloom <gedare@rtems.org>2013-02-07 17:02:12 -0500
commitfb9fa1537a9765eae90124e5db5770ae7a527d5e (patch)
treefa5d90b8c66a7bc242f24787e01329e0d8d48c78
parentscore: atomic support for RTEMS. Atomic operations for PowerPC. (diff)
downloadrtems-fb9fa1537a9765eae90124e5db5770ae7a527d5e.tar.bz2
tests: atomic support for RTEMS. Uniprocessor tests for atomic ops.
-rw-r--r--testsuites/sptests/spatomic01/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic01/init.c63
-rw-r--r--testsuites/sptests/spatomic01/spatomic01.doc23
-rw-r--r--testsuites/sptests/spatomic01/spatomic01.scn70
-rw-r--r--testsuites/sptests/spatomic01/system.h51
-rw-r--r--testsuites/sptests/spatomic01/tasks.c100
-rw-r--r--testsuites/sptests/spatomic02/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic02/init.c69
-rw-r--r--testsuites/sptests/spatomic02/spatomic02.doc23
-rw-r--r--testsuites/sptests/spatomic02/spatomic02.scn70
-rw-r--r--testsuites/sptests/spatomic02/system.h51
-rw-r--r--testsuites/sptests/spatomic02/tasks.c101
-rw-r--r--testsuites/sptests/spatomic03/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic03/init.c69
-rw-r--r--testsuites/sptests/spatomic03/spatomic03.doc23
-rw-r--r--testsuites/sptests/spatomic03/spatomic03.scn102
-rw-r--r--testsuites/sptests/spatomic03/system.h51
-rw-r--r--testsuites/sptests/spatomic03/tasks.c110
-rw-r--r--testsuites/sptests/spatomic04/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic04/init.c69
-rw-r--r--testsuites/sptests/spatomic04/spatomic04.doc23
-rw-r--r--testsuites/sptests/spatomic04/spatomic04.scn102
-rw-r--r--testsuites/sptests/spatomic04/system.h51
-rw-r--r--testsuites/sptests/spatomic04/tasks.c110
-rw-r--r--testsuites/sptests/spatomic05/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic05/init.c69
-rw-r--r--testsuites/sptests/spatomic05/spatomic05.doc23
-rw-r--r--testsuites/sptests/spatomic05/spatomic05.scn102
-rw-r--r--testsuites/sptests/spatomic05/system.h51
-rw-r--r--testsuites/sptests/spatomic05/tasks.c109
-rw-r--r--testsuites/sptests/spatomic06/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic06/init.c69
-rw-r--r--testsuites/sptests/spatomic06/spatomic06.doc23
-rw-r--r--testsuites/sptests/spatomic06/spatomic06.scn102
-rw-r--r--testsuites/sptests/spatomic06/system.h51
-rw-r--r--testsuites/sptests/spatomic06/tasks.c109
-rw-r--r--testsuites/sptests/spatomic07/Makefile.am22
-rw-r--r--testsuites/sptests/spatomic07/init.c69
-rw-r--r--testsuites/sptests/spatomic07/spatomic07.doc24
-rw-r--r--testsuites/sptests/spatomic07/spatomic07.scn102
-rw-r--r--testsuites/sptests/spatomic07/system.h51
-rw-r--r--testsuites/sptests/spatomic07/tasks.c124
42 files changed, 2563 insertions, 0 deletions
diff --git a/testsuites/sptests/spatomic01/Makefile.am b/testsuites/sptests/spatomic01/Makefile.am
new file mode 100644
index 0000000000..760b17b73e
--- /dev/null
+++ b/testsuites/sptests/spatomic01/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic01
+spatomic01_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic01.scn
+dist_rtems_tests_DATA += spatomic01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic01_OBJECTS)
+LINK_LIBS = $(spatomic01_LDLIBS)
+
+spatomic01$(EXEEXT): $(spatomic01_OBJECTS) $(spatomic01_DEPENDENCIES)
+ @rm -f spatomic01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic01/init.c b/testsuites/sptests/spatomic01/init.c
new file mode 100644
index 0000000000..7326bf7c95
--- /dev/null
+++ b/testsuites/sptests/spatomic01/init.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic load operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic01 TEST ***\n" );
+
+ /* Create and start tasks to test */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic01/spatomic01.doc b/testsuites/sptests/spatomic01/spatomic01.doc
new file mode 100644
index 0000000000..dc322a3f55
--- /dev/null
+++ b/testsuites/sptests/spatomic01/spatomic01.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic01
+
+directives:
+
+ _Atomic_Load_int
+ _Atomic_Load_long
+ _Atomic_Load_ptr
+ _Atomic_Load_32
+ _Atomic_Load_64
+
+concepts:
+
++ Ensure that the atomic load operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic01/spatomic01.scn b/testsuites/sptests/spatomic01/spatomic01.scn
new file mode 100644
index 0000000000..9979d8033c
--- /dev/null
+++ b/testsuites/sptests/spatomic01/spatomic01.scn
@@ -0,0 +1,70 @@
+*** spatomic01 TEST ***
+
+
+task0: _Atomic_Load_int: SUCCESS
+
+task0: _Atomic_Load_long: SUCCESS
+
+task0: _Atomic_Load_ptr: SUCCESS
+
+task0: _Atomic_Load_32: SUCCESS
+
+task0: _Atomic_Load_int: SUCCESS
+
+task0: _Atomic_Load_long: SUCCESS
+
+task0: _Atomic_Load_ptr: SUCCESS
+
+task0: _Atomic_Load_32: SUCCESS
+
+task1: _Atomic_Load_int: SUCCESS
+
+task1: _Atomic_Load_long: SUCCESS
+
+task1: _Atomic_Load_ptr: SUCCESS
+
+task1: _Atomic_Load_32: SUCCESS
+
+task1: _Atomic_Load_int: SUCCESS
+
+task1: _Atomic_Load_long: SUCCESS
+
+task1: _Atomic_Load_ptr: SUCCESS
+
+task1: _Atomic_Load_32: SUCCESS
+
+task2: _Atomic_Load_int: SUCCESS
+
+task2: _Atomic_Load_long: SUCCESS
+
+task2: _Atomic_Load_ptr: SUCCESS
+
+task2: _Atomic_Load_32: SUCCESS
+
+task2: _Atomic_Load_int: SUCCESS
+
+task2: _Atomic_Load_long: SUCCESS
+
+task2: _Atomic_Load_ptr: SUCCESS
+
+task2: _Atomic_Load_32: SUCCESS
+
+task3: _Atomic_Load_int: SUCCESS
+
+task3: _Atomic_Load_long: SUCCESS
+
+task3: _Atomic_Load_ptr: SUCCESS
+
+task3: _Atomic_Load_32: SUCCESS
+
+task3: _Atomic_Load_int: SUCCESS
+
+task3: _Atomic_Load_long: SUCCESS
+
+task3: _Atomic_Load_ptr: SUCCESS
+
+task3: _Atomic_Load_32: SUCCESS
+
+
+*** END OF TEST spatomic01 ***
+
diff --git a/testsuites/sptests/spatomic01/system.h b/testsuites/sptests/spatomic01/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic01/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic01/tasks.c b/testsuites/sptests/spatomic01/tasks.c
new file mode 100644
index 0000000000..c75a94d679
--- /dev/null
+++ b/testsuites/sptests/spatomic01/tasks.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic load operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+{ \
+ Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0; \
+ 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(); \
+ a = _Atomic_Load_##NAME(&t, mem_bar); \
+ rtems_test_assert(a == t); \
+ } \
+ printf("\ntask%d: _Atomic_Load_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_LOAD_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_LOAD_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic01 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
diff --git a/testsuites/sptests/spatomic02/Makefile.am b/testsuites/sptests/spatomic02/Makefile.am
new file mode 100644
index 0000000000..3c9b1eb67c
--- /dev/null
+++ b/testsuites/sptests/spatomic02/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic02
+spatomic02_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic02.scn
+dist_rtems_tests_DATA += spatomic02.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic02_OBJECTS)
+LINK_LIBS = $(spatomic02_LDLIBS)
+
+spatomic02$(EXEEXT): $(spatomic02_OBJECTS) $(spatomic02_DEPENDENCIES)
+ @rm -f spatomic01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic02/init.c b/testsuites/sptests/spatomic02/init.c
new file mode 100644
index 0000000000..0c1b32e4ca
--- /dev/null
+++ b/testsuites/sptests/spatomic02/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic store operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic02 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic02/spatomic02.doc b/testsuites/sptests/spatomic02/spatomic02.doc
new file mode 100644
index 0000000000..70e674422d
--- /dev/null
+++ b/testsuites/sptests/spatomic02/spatomic02.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic02
+
+directives:
+
+ _Atomic_Store_int
+ _Atomic_Store_long
+ _Atomic_Store_ptr
+ _Atomic_Store_32
+ _Atomic_Store_64
+
+concepts:
+
++ Ensure that the atomic store operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic02/spatomic02.scn b/testsuites/sptests/spatomic02/spatomic02.scn
new file mode 100644
index 0000000000..31ba7e977c
--- /dev/null
+++ b/testsuites/sptests/spatomic02/spatomic02.scn
@@ -0,0 +1,70 @@
+*** spatomic02 TEST ***
+
+
+task0: _Atomic_Store_int: SUCCESS
+
+task0: _Atomic_Store_long: SUCCESS
+
+task0: _Atomic_Store_ptr: SUCCESS
+
+task0: _Atomic_Store_32: SUCCESS
+
+task0: _Atomic_Store_int: SUCCESS
+
+task0: _Atomic_Store_long: SUCCESS
+
+task0: _Atomic_Store_ptr: SUCCESS
+
+task0: _Atomic_Store_32: SUCCESS
+
+task1: _Atomic_Store_int: SUCCESS
+
+task1: _Atomic_Store_long: SUCCESS
+
+task1: _Atomic_Store_ptr: SUCCESS
+
+task1: _Atomic_Store_32: SUCCESS
+
+task1: _Atomic_Store_int: SUCCESS
+
+task1: _Atomic_Store_long: SUCCESS
+
+task1: _Atomic_Store_ptr: SUCCESS
+
+task1: _Atomic_Store_32: SUCCESS
+
+task2: _Atomic_Store_int: SUCCESS
+
+task2: _Atomic_Store_long: SUCCESS
+
+task2: _Atomic_Store_ptr: SUCCESS
+
+task2: _Atomic_Store_32: SUCCESS
+
+task2: _Atomic_Store_int: SUCCESS
+
+task2: _Atomic_Store_long: SUCCESS
+
+task2: _Atomic_Store_ptr: SUCCESS
+
+task2: _Atomic_Store_32: SUCCESS
+
+task3: _Atomic_Store_int: SUCCESS
+
+task3: _Atomic_Store_long: SUCCESS
+
+task3: _Atomic_Store_ptr: SUCCESS
+
+task3: _Atomic_Store_32: SUCCESS
+
+task3: _Atomic_Store_int: SUCCESS
+
+task3: _Atomic_Store_long: SUCCESS
+
+task3: _Atomic_Store_ptr: SUCCESS
+
+task3: _Atomic_Store_32: SUCCESS
+
+
+*** END OF TEST spatomic02 ***
+
diff --git a/testsuites/sptests/spatomic02/system.h b/testsuites/sptests/spatomic02/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic02/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic02/tasks.c b/testsuites/sptests/spatomic02/tasks.c
new file mode 100644
index 0000000000..67c2460885
--- /dev/null
+++ b/testsuites/sptests/spatomic02/tasks.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic store operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+{ \
+ Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0; \
+ 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); \
+ } \
+ printf("\ntask%d: _Atomic_Store_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_STORE_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_STORE_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_STORE_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_STORE_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_STORE_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_STORE_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic02 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
+
diff --git a/testsuites/sptests/spatomic03/Makefile.am b/testsuites/sptests/spatomic03/Makefile.am
new file mode 100644
index 0000000000..e9b880b30d
--- /dev/null
+++ b/testsuites/sptests/spatomic03/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic03
+spatomic03_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic03.scn
+dist_rtems_tests_DATA += spatomic03.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic03_OBJECTS)
+LINK_LIBS = $(spatomic03_LDLIBS)
+
+spatomic03$(EXEEXT): $(spatomic03_OBJECTS) $(spatomic03_DEPENDENCIES)
+ @rm -f spatomic03$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic03/init.c b/testsuites/sptests/spatomic03/init.c
new file mode 100644
index 0000000000..3f06d0ec9c
--- /dev/null
+++ b/testsuites/sptests/spatomic03/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic add operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic03 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic03/spatomic03.doc b/testsuites/sptests/spatomic03/spatomic03.doc
new file mode 100644
index 0000000000..130dca9169
--- /dev/null
+++ b/testsuites/sptests/spatomic03/spatomic03.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic03
+
+directives:
+
+ _Atomic_Fetch_add_int
+ _Atomic_Fetch_add_long
+ _Atomic_Fetch_add_ptr
+ _Atomic_Fetch_add_32
+ _Atomic_Fetch_add_64
+
+concepts:
+
++ Ensure that the atomic add operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic03/spatomic03.scn b/testsuites/sptests/spatomic03/spatomic03.scn
new file mode 100644
index 0000000000..69216e5ab0
--- /dev/null
+++ b/testsuites/sptests/spatomic03/spatomic03.scn
@@ -0,0 +1,102 @@
+*** spatomic03 TEST ***
+
+
+task0: _Atomic_Fetch_add_int: SUCCESS
+
+task0: _Atomic_Fetch_add_long: SUCCESS
+
+task0: _Atomic_Fetch_add_ptr: SUCCESS
+
+task0: _Atomic_Fetch_add_32: SUCCESS
+
+task0: _Atomic_Fetch_add_int: SUCCESS
+
+task0: _Atomic_Fetch_add_long: SUCCESS
+
+task0: _Atomic_Fetch_add_ptr: SUCCESS
+
+task0: _Atomic_Fetch_add_32: SUCCESS
+
+task0: _Atomic_Fetch_add_int: SUCCESS
+
+task0: _Atomic_Fetch_add_long: SUCCESS
+
+task0: _Atomic_Fetch_add_ptr: SUCCESS
+
+task0: _Atomic_Fetch_add_32: SUCCESS
+
+task1: _Atomic_Fetch_add_int: SUCCESS
+
+task1: _Atomic_Fetch_add_long: SUCCESS
+
+task1: _Atomic_Fetch_add_ptr: SUCCESS
+
+task1: _Atomic_Fetch_add_32: SUCCESS
+
+task1: _Atomic_Fetch_add_int: SUCCESS
+
+task1: _Atomic_Fetch_add_long: SUCCESS
+
+task1: _Atomic_Fetch_add_ptr: SUCCESS
+
+task1: _Atomic_Fetch_add_32: SUCCESS
+
+task1: _Atomic_Fetch_add_int: SUCCESS
+
+task1: _Atomic_Fetch_add_long: SUCCESS
+
+task1: _Atomic_Fetch_add_ptr: SUCCESS
+
+task1: _Atomic_Fetch_add_32: SUCCESS
+
+task2: _Atomic_Fetch_add_int: SUCCESS
+
+task2: _Atomic_Fetch_add_long: SUCCESS
+
+task2: _Atomic_Fetch_add_ptr: SUCCESS
+
+task2: _Atomic_Fetch_add_32: SUCCESS
+
+task2: _Atomic_Fetch_add_int: SUCCESS
+
+task2: _Atomic_Fetch_add_long: SUCCESS
+
+task2: _Atomic_Fetch_add_ptr: SUCCESS
+
+task2: _Atomic_Fetch_add_32: SUCCESS
+
+task2: _Atomic_Fetch_add_int: SUCCESS
+
+task2: _Atomic_Fetch_add_long: SUCCESS
+
+task2: _Atomic_Fetch_add_ptr: SUCCESS
+
+task2: _Atomic_Fetch_add_32: SUCCESS
+
+task3: _Atomic_Fetch_add_int: SUCCESS
+
+task3: _Atomic_Fetch_add_long: SUCCESS
+
+task3: _Atomic_Fetch_add_ptr: SUCCESS
+
+task3: _Atomic_Fetch_add_32: SUCCESS
+
+task3: _Atomic_Fetch_add_int: SUCCESS
+
+task3: _Atomic_Fetch_add_long: SUCCESS
+
+task3: _Atomic_Fetch_add_ptr: SUCCESS
+
+task3: _Atomic_Fetch_add_32: SUCCESS
+
+task3: _Atomic_Fetch_add_int: SUCCESS
+
+task3: _Atomic_Fetch_add_long: SUCCESS
+
+task3: _Atomic_Fetch_add_ptr: SUCCESS
+
+task3: _Atomic_Fetch_add_32: SUCCESS
+
+
+*** END OF TEST spatomic03 ***
+
diff --git a/testsuites/sptests/spatomic03/system.h b/testsuites/sptests/spatomic03/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic03/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic03/tasks.c b/testsuites/sptests/spatomic03/tasks.c
new file mode 100644
index 0000000000..2218b1b823
--- /dev/null
+++ b/testsuites/sptests/spatomic03/tasks.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic add operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_FETCH_ADD_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+{ \
+ Atomic_##TYPE t = 0, a = 0, b = 0; \
+ 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; \
+ _Atomic_Fetch_add_##NAME(&t, b, mem_bar); \
+ rtems_test_assert(t == (Atomic_##TYPE)(a + b)); \
+ } \
+ printf("\ntask%d: _Atomic_Fetch_add_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_FETCH_ADD_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_ADD_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic03 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
+
diff --git a/testsuites/sptests/spatomic04/Makefile.am b/testsuites/sptests/spatomic04/Makefile.am
new file mode 100644
index 0000000000..6ecc55677e
--- /dev/null
+++ b/testsuites/sptests/spatomic04/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic04
+spatomic04_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic04.scn
+dist_rtems_tests_DATA += spatomic04.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic04_OBJECTS)
+LINK_LIBS = $(spatomic04_LDLIBS)
+
+spatomic04$(EXEEXT): $(spatomic04_OBJECTS) $(spatomic04_DEPENDENCIES)
+ @rm -f spatomic04$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic04/init.c b/testsuites/sptests/spatomic04/init.c
new file mode 100644
index 0000000000..655b081e9e
--- /dev/null
+++ b/testsuites/sptests/spatomic04/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic sub operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic04 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic04/spatomic04.doc b/testsuites/sptests/spatomic04/spatomic04.doc
new file mode 100644
index 0000000000..6fc8f09cc4
--- /dev/null
+++ b/testsuites/sptests/spatomic04/spatomic04.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic04
+
+directives:
+
+ _Atomic_Fetch_sub_int
+ _Atomic_Fetch_sub_long
+ _Atomic_Fetch_sub_ptr
+ _Atomic_Fetch_sub_32
+ _Atomic_Fetch_sub_64
+
+concepts:
+
++ Ensure that the atomic sub operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic04/spatomic04.scn b/testsuites/sptests/spatomic04/spatomic04.scn
new file mode 100644
index 0000000000..550e87e791
--- /dev/null
+++ b/testsuites/sptests/spatomic04/spatomic04.scn
@@ -0,0 +1,102 @@
+patomic04 TEST ***
+
+
+task0: _Atomic_Fetch_sub_int: SUCCESS
+
+task0: _Atomic_Fetch_sub_long: SUCCESS
+
+task0: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task0: _Atomic_Fetch_sub_32: SUCCESS
+
+task0: _Atomic_Fetch_sub_int: SUCCESS
+
+task0: _Atomic_Fetch_sub_long: SUCCESS
+
+task0: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task0: _Atomic_Fetch_sub_32: SUCCESS
+
+task0: _Atomic_Fetch_sub_int: SUCCESS
+
+task0: _Atomic_Fetch_sub_long: SUCCESS
+
+task0: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task0: _Atomic_Fetch_sub_32: SUCCESS
+
+task1: _Atomic_Fetch_sub_int: SUCCESS
+
+task1: _Atomic_Fetch_sub_long: SUCCESS
+
+task1: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task1: _Atomic_Fetch_sub_32: SUCCESS
+
+task1: _Atomic_Fetch_sub_int: SUCCESS
+
+task1: _Atomic_Fetch_sub_long: SUCCESS
+
+task1: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task1: _Atomic_Fetch_sub_32: SUCCESS
+
+task1: _Atomic_Fetch_sub_int: SUCCESS
+
+task1: _Atomic_Fetch_sub_long: SUCCESS
+
+task1: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task1: _Atomic_Fetch_sub_32: SUCCESS
+
+task2: _Atomic_Fetch_sub_int: SUCCESS
+
+task2: _Atomic_Fetch_sub_long: SUCCESS
+
+task2: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task2: _Atomic_Fetch_sub_32: SUCCESS
+
+task2: _Atomic_Fetch_sub_int: SUCCESS
+
+task2: _Atomic_Fetch_sub_long: SUCCESS
+
+task2: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task2: _Atomic_Fetch_sub_32: SUCCESS
+
+task2: _Atomic_Fetch_sub_int: SUCCESS
+
+task2: _Atomic_Fetch_sub_long: SUCCESS
+
+task2: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task2: _Atomic_Fetch_sub_32: SUCCESS
+
+task3: _Atomic_Fetch_sub_int: SUCCESS
+
+task3: _Atomic_Fetch_sub_long: SUCCESS
+
+task3: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task3: _Atomic_Fetch_sub_32: SUCCESS
+
+task3: _Atomic_Fetch_sub_int: SUCCESS
+
+task3: _Atomic_Fetch_sub_long: SUCCESS
+
+task3: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task3: _Atomic_Fetch_sub_32: SUCCESS
+
+task3: _Atomic_Fetch_sub_int: SUCCESS
+
+task3: _Atomic_Fetch_sub_long: SUCCESS
+
+task3: _Atomic_Fetch_sub_ptr: SUCCESS
+
+task3: _Atomic_Fetch_sub_32: SUCCESS
+
+
+*** END OF TEST spatomic04 ***
+
diff --git a/testsuites/sptests/spatomic04/system.h b/testsuites/sptests/spatomic04/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic04/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic04/tasks.c b/testsuites/sptests/spatomic04/tasks.c
new file mode 100644
index 0000000000..4600f398ad
--- /dev/null
+++ b/testsuites/sptests/spatomic04/tasks.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic sub operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_FETCH_SUB_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+{ \
+ Atomic_##TYPE t = 0, a = 0, b = 0; \
+ 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; \
+ _Atomic_Fetch_sub_##NAME(&t, b, mem_bar); \
+ rtems_test_assert(t == (Atomic_##TYPE)(a - b)); \
+ } \
+ printf("\ntask%d: _Atomic_Fetch_sub_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_FETCH_SUB_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_SUB_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic04 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
+
diff --git a/testsuites/sptests/spatomic05/Makefile.am b/testsuites/sptests/spatomic05/Makefile.am
new file mode 100644
index 0000000000..bfa459d6e0
--- /dev/null
+++ b/testsuites/sptests/spatomic05/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic05
+spatomic05_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic05.scn
+dist_rtems_tests_DATA += spatomic05.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic05_OBJECTS)
+LINK_LIBS = $(spatomic05_LDLIBS)
+
+spatomic05$(EXEEXT): $(spatomic05_OBJECTS) $(spatomic05_DEPENDENCIES)
+ @rm -f spatomic05$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic05/init.c b/testsuites/sptests/spatomic05/init.c
new file mode 100644
index 0000000000..891af2866d
--- /dev/null
+++ b/testsuites/sptests/spatomic05/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic and operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic05 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic05/spatomic05.doc b/testsuites/sptests/spatomic05/spatomic05.doc
new file mode 100644
index 0000000000..018dd64a3b
--- /dev/null
+++ b/testsuites/sptests/spatomic05/spatomic05.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic05
+
+directives:
+
+ _Atomic_Fetch_and_int
+ _Atomic_Fetch_and_long
+ _Atomic_Fetch_and_ptr
+ _Atomic_Fetch_and_32
+ _Atomic_Fetch_and_64
+
+concepts:
+
++ Ensure that the atomic and operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic05/spatomic05.scn b/testsuites/sptests/spatomic05/spatomic05.scn
new file mode 100644
index 0000000000..84020b9d68
--- /dev/null
+++ b/testsuites/sptests/spatomic05/spatomic05.scn
@@ -0,0 +1,102 @@
+patomic05 TEST ***
+
+
+task0: _Atomic_Fetch_and_int: SUCCESS
+
+task0: _Atomic_Fetch_and_long: SUCCESS
+
+task0: _Atomic_Fetch_and_ptr: SUCCESS
+
+task0: _Atomic_Fetch_and_32: SUCCESS
+
+task0: _Atomic_Fetch_and_int: SUCCESS
+
+task0: _Atomic_Fetch_and_long: SUCCESS
+
+task0: _Atomic_Fetch_and_ptr: SUCCESS
+
+task0: _Atomic_Fetch_and_32: SUCCESS
+
+task0: _Atomic_Fetch_and_int: SUCCESS
+
+task0: _Atomic_Fetch_and_long: SUCCESS
+
+task0: _Atomic_Fetch_and_ptr: SUCCESS
+
+task0: _Atomic_Fetch_and_32: SUCCESS
+
+task1: _Atomic_Fetch_and_int: SUCCESS
+
+task1: _Atomic_Fetch_and_long: SUCCESS
+
+task1: _Atomic_Fetch_and_ptr: SUCCESS
+
+task1: _Atomic_Fetch_and_32: SUCCESS
+
+task1: _Atomic_Fetch_and_int: SUCCESS
+
+task1: _Atomic_Fetch_and_long: SUCCESS
+
+task1: _Atomic_Fetch_and_ptr: SUCCESS
+
+task1: _Atomic_Fetch_and_32: SUCCESS
+
+task1: _Atomic_Fetch_and_int: SUCCESS
+
+task1: _Atomic_Fetch_and_long: SUCCESS
+
+task1: _Atomic_Fetch_and_ptr: SUCCESS
+
+task1: _Atomic_Fetch_and_32: SUCCESS
+
+task2: _Atomic_Fetch_and_int: SUCCESS
+
+task2: _Atomic_Fetch_and_long: SUCCESS
+
+task2: _Atomic_Fetch_and_ptr: SUCCESS
+
+task2: _Atomic_Fetch_and_32: SUCCESS
+
+task2: _Atomic_Fetch_and_int: SUCCESS
+
+task2: _Atomic_Fetch_and_long: SUCCESS
+
+task2: _Atomic_Fetch_and_ptr: SUCCESS
+
+task2: _Atomic_Fetch_and_32: SUCCESS
+
+task2: _Atomic_Fetch_and_int: SUCCESS
+
+task2: _Atomic_Fetch_and_long: SUCCESS
+
+task2: _Atomic_Fetch_and_ptr: SUCCESS
+
+task2: _Atomic_Fetch_and_32: SUCCESS
+
+task3: _Atomic_Fetch_and_int: SUCCESS
+
+task3: _Atomic_Fetch_and_long: SUCCESS
+
+task3: _Atomic_Fetch_and_ptr: SUCCESS
+
+task3: _Atomic_Fetch_and_32: SUCCESS
+
+task3: _Atomic_Fetch_and_int: SUCCESS
+
+task3: _Atomic_Fetch_and_long: SUCCESS
+
+task3: _Atomic_Fetch_and_ptr: SUCCESS
+
+task3: _Atomic_Fetch_and_32: SUCCESS
+
+task3: _Atomic_Fetch_and_int: SUCCESS
+
+task3: _Atomic_Fetch_and_long: SUCCESS
+
+task3: _Atomic_Fetch_and_ptr: SUCCESS
+
+task3: _Atomic_Fetch_and_32: SUCCESS
+
+
+*** END OF TEST spatomic05 ***
+
diff --git a/testsuites/sptests/spatomic05/system.h b/testsuites/sptests/spatomic05/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic05/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic05/tasks.c b/testsuites/sptests/spatomic05/tasks.c
new file mode 100644
index 0000000000..d0df98ad0d
--- /dev/null
+++ b/testsuites/sptests/spatomic05/tasks.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic and operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_FETCH_AND_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+{ \
+ Atomic_##TYPE t = 0, a = 0, b = 0; \
+ 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; \
+ _Atomic_Fetch_and_##NAME(&t, b, mem_bar); \
+ rtems_test_assert(t == (Atomic_##TYPE)(a & b)); \
+ } \
+ printf("\ntask%d: _Atomic_Fetch_and_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_FETCH_AND_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_FETCH_AND_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_AND_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic05 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
diff --git a/testsuites/sptests/spatomic06/Makefile.am b/testsuites/sptests/spatomic06/Makefile.am
new file mode 100644
index 0000000000..4efc86553b
--- /dev/null
+++ b/testsuites/sptests/spatomic06/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic06
+spatomic06_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic06.scn
+dist_rtems_tests_DATA += spatomic06.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic06_OBJECTS)
+LINK_LIBS = $(spatomic06_LDLIBS)
+
+spatomic06$(EXEEXT): $(spatomic06_OBJECTS) $(spatomic06_DEPENDENCIES)
+ @rm -f spatomic06$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic06/init.c b/testsuites/sptests/spatomic06/init.c
new file mode 100644
index 0000000000..775c6bc345
--- /dev/null
+++ b/testsuites/sptests/spatomic06/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic or operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic06 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic06/spatomic06.doc b/testsuites/sptests/spatomic06/spatomic06.doc
new file mode 100644
index 0000000000..5a4d033c4f
--- /dev/null
+++ b/testsuites/sptests/spatomic06/spatomic06.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic06
+
+directives:
+
+ _Atomic_Fetch_or_int
+ _Atomic_Fetch_or_long
+ _Atomic_Fetch_or_ptr
+ _Atomic_Fetch_or_32
+ _Atomic_Fetch_or_64
+
+concepts:
+
++ Ensure that the atomic or operations listed above behave as defined.
diff --git a/testsuites/sptests/spatomic06/spatomic06.scn b/testsuites/sptests/spatomic06/spatomic06.scn
new file mode 100644
index 0000000000..14290616ba
--- /dev/null
+++ b/testsuites/sptests/spatomic06/spatomic06.scn
@@ -0,0 +1,102 @@
+*** spatomic06 TEST ***
+
+
+task0: _Atomic_Fetch_or_int: SUCCESS
+
+task0: _Atomic_Fetch_or_long: SUCCESS
+
+task0: _Atomic_Fetch_or_ptr: SUCCESS
+
+task0: _Atomic_Fetch_or_32: SUCCESS
+
+task0: _Atomic_Fetch_or_int: SUCCESS
+
+task0: _Atomic_Fetch_or_long: SUCCESS
+
+task0: _Atomic_Fetch_or_ptr: SUCCESS
+
+task0: _Atomic_Fetch_or_32: SUCCESS
+
+task0: _Atomic_Fetch_or_int: SUCCESS
+
+task0: _Atomic_Fetch_or_long: SUCCESS
+
+task0: _Atomic_Fetch_or_ptr: SUCCESS
+
+task0: _Atomic_Fetch_or_32: SUCCESS
+
+task1: _Atomic_Fetch_or_int: SUCCESS
+
+task1: _Atomic_Fetch_or_long: SUCCESS
+
+task1: _Atomic_Fetch_or_ptr: SUCCESS
+
+task1: _Atomic_Fetch_or_32: SUCCESS
+
+task1: _Atomic_Fetch_or_int: SUCCESS
+
+task1: _Atomic_Fetch_or_long: SUCCESS
+
+task1: _Atomic_Fetch_or_ptr: SUCCESS
+
+task1: _Atomic_Fetch_or_32: SUCCESS
+
+task1: _Atomic_Fetch_or_int: SUCCESS
+
+task1: _Atomic_Fetch_or_long: SUCCESS
+
+task1: _Atomic_Fetch_or_ptr: SUCCESS
+
+task1: _Atomic_Fetch_or_32: SUCCESS
+
+task2: _Atomic_Fetch_or_int: SUCCESS
+
+task2: _Atomic_Fetch_or_long: SUCCESS
+
+task2: _Atomic_Fetch_or_ptr: SUCCESS
+
+task2: _Atomic_Fetch_or_32: SUCCESS
+
+task2: _Atomic_Fetch_or_int: SUCCESS
+
+task2: _Atomic_Fetch_or_long: SUCCESS
+
+task2: _Atomic_Fetch_or_ptr: SUCCESS
+
+task2: _Atomic_Fetch_or_32: SUCCESS
+
+task2: _Atomic_Fetch_or_int: SUCCESS
+
+task2: _Atomic_Fetch_or_long: SUCCESS
+
+task2: _Atomic_Fetch_or_ptr: SUCCESS
+
+task2: _Atomic_Fetch_or_32: SUCCESS
+
+task3: _Atomic_Fetch_or_int: SUCCESS
+
+task3: _Atomic_Fetch_or_long: SUCCESS
+
+task3: _Atomic_Fetch_or_ptr: SUCCESS
+
+task3: _Atomic_Fetch_or_32: SUCCESS
+
+task3: _Atomic_Fetch_or_int: SUCCESS
+
+task3: _Atomic_Fetch_or_long: SUCCESS
+
+task3: _Atomic_Fetch_or_ptr: SUCCESS
+
+task3: _Atomic_Fetch_or_32: SUCCESS
+
+task3: _Atomic_Fetch_or_int: SUCCESS
+
+task3: _Atomic_Fetch_or_long: SUCCESS
+
+task3: _Atomic_Fetch_or_ptr: SUCCESS
+
+task3: _Atomic_Fetch_or_32: SUCCESS
+
+
+*** END OF TEST spatomic06 ***
+
diff --git a/testsuites/sptests/spatomic06/system.h b/testsuites/sptests/spatomic06/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic06/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic06/tasks.c b/testsuites/sptests/spatomic06/tasks.c
new file mode 100644
index 0000000000..753b91ae73
--- /dev/null
+++ b/testsuites/sptests/spatomic06/tasks.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic or operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_FETCH_OR_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+{ \
+ Atomic_##TYPE t = 0, a = 0, b = 0; \
+ 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; \
+ _Atomic_Fetch_or_##NAME(&t, b, mem_bar); \
+ rtems_test_assert(t == (Atomic_##TYPE)(a | b)); \
+ } \
+ printf("\ntask%d: _Atomic_Fetch_or_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_FETCH_OR_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_FETCH_OR_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_FETCH_OR_NO_BARRIER(ptr, Pointer, 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;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic06 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}
diff --git a/testsuites/sptests/spatomic07/Makefile.am b/testsuites/sptests/spatomic07/Makefile.am
new file mode 100644
index 0000000000..6b07b29a25
--- /dev/null
+++ b/testsuites/sptests/spatomic07/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = spatomic07
+spatomic07_SOURCES = init.c tasks.c system.h
+
+dist_rtems_tests_DATA = spatomic07.scn
+dist_rtems_tests_DATA += spatomic07.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spatomic07_OBJECTS)
+LINK_LIBS = $(spatomic07_LDLIBS)
+
+spatomic07$(EXEEXT): $(spatomic07_OBJECTS) $(spatomic07_DEPENDENCIES)
+ @rm -f spatomic07$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spatomic07/init.c b/testsuites/sptests/spatomic07/init.c
new file mode 100644
index 0000000000..8d03464f37
--- /dev/null
+++ b/testsuites/sptests/spatomic07/init.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic compare and exchange operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ int i;
+ char ch;
+ rtems_id id;
+ rtems_status_code status;
+ bool allDone;
+
+ /* Put start of test message */
+ puts( "\n\n*** spatomic07 TEST ***\n" );
+
+ /* Initialize the TaskRan array */
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ TaskRan[i] = false;
+ }
+
+ /* Create and start tasks for each processor */
+ for ( i=0; i< TASK_NUMS ; i++ ) {
+ ch = '0' + i;
+
+ status = rtems_task_create(
+ rtems_build_name( 'T', 'A', ch, ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Test_task, i );
+ directive_failed( status, "task start" );
+ }
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'T', '0', ' ' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ directive_failed( status, "task create" );
+
+ status = rtems_task_start( id, Wait_task, 0 );
+ directive_failed( status, "task start" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
diff --git a/testsuites/sptests/spatomic07/spatomic07.doc b/testsuites/sptests/spatomic07/spatomic07.doc
new file mode 100644
index 0000000000..4ade88f4f9
--- /dev/null
+++ b/testsuites/sptests/spatomic07/spatomic07.doc
@@ -0,0 +1,24 @@
+# COPYRIGHT (c) 1989-2012.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spatomic07
+
+directives:
+
+ _Atomic_Compare_exchange_int
+ _Atomic_Compare_exchange_long
+ _Atomic_Compare_exchange_ptr
+ _Atomic_Compare_exchange_32
+ _Atomic_Compare_exchange_64
+
+concepts:
+
++ Ensure that the atomic compare and exchange operations listed above behave
+ as defined.
diff --git a/testsuites/sptests/spatomic07/spatomic07.scn b/testsuites/sptests/spatomic07/spatomic07.scn
new file mode 100644
index 0000000000..bb37ba6910
--- /dev/null
+++ b/testsuites/sptests/spatomic07/spatomic07.scn
@@ -0,0 +1,102 @@
+patomic07 TEST ***
+
+
+task0: _Atomic_Compare_exchange_int: SUCCESS
+
+task0: _Atomic_Compare_exchange_long: SUCCESS
+
+task0: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task0: _Atomic_Compare_exchange_32: SUCCESS
+
+task0: _Atomic_Compare_exchange_int: SUCCESS
+
+task0: _Atomic_Compare_exchange_long: SUCCESS
+
+task0: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task0: _Atomic_Compare_exchange_32: SUCCESS
+
+task0: _Atomic_Compare_exchange_int: SUCCESS
+
+task0: _Atomic_Compare_exchange_long: SUCCESS
+
+task0: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task0: _Atomic_Compare_exchange_32: SUCCESS
+
+task1: _Atomic_Compare_exchange_int: SUCCESS
+
+task1: _Atomic_Compare_exchange_long: SUCCESS
+
+task1: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task1: _Atomic_Compare_exchange_32: SUCCESS
+
+task1: _Atomic_Compare_exchange_int: SUCCESS
+
+task1: _Atomic_Compare_exchange_long: SUCCESS
+
+task1: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task1: _Atomic_Compare_exchange_32: SUCCESS
+
+task1: _Atomic_Compare_exchange_int: SUCCESS
+
+task1: _Atomic_Compare_exchange_long: SUCCESS
+
+task1: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task1: _Atomic_Compare_exchange_32: SUCCESS
+
+task2: _Atomic_Compare_exchange_int: SUCCESS
+
+task2: _Atomic_Compare_exchange_long: SUCCESS
+
+task2: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task2: _Atomic_Compare_exchange_32: SUCCESS
+
+task2: _Atomic_Compare_exchange_int: SUCCESS
+
+task2: _Atomic_Compare_exchange_long: SUCCESS
+
+task2: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task2: _Atomic_Compare_exchange_32: SUCCESS
+
+task2: _Atomic_Compare_exchange_int: SUCCESS
+
+task2: _Atomic_Compare_exchange_long: SUCCESS
+
+task2: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task2: _Atomic_Compare_exchange_32: SUCCESS
+
+task3: _Atomic_Compare_exchange_int: SUCCESS
+
+task3: _Atomic_Compare_exchange_long: SUCCESS
+
+task3: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task3: _Atomic_Compare_exchange_32: SUCCESS
+
+task3: _Atomic_Compare_exchange_int: SUCCESS
+
+task3: _Atomic_Compare_exchange_long: SUCCESS
+
+task3: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task3: _Atomic_Compare_exchange_32: SUCCESS
+
+task3: _Atomic_Compare_exchange_int: SUCCESS
+
+task3: _Atomic_Compare_exchange_long: SUCCESS
+
+task3: _Atomic_Compare_exchange_ptr: SUCCESS
+
+task3: _Atomic_Compare_exchange_32: SUCCESS
+
+
+*** END OF TEST spatomic07 ***
+
diff --git a/testsuites/sptests/spatomic07/system.h b/testsuites/sptests/spatomic07/system.h
new file mode 100644
index 0000000000..55931f24c0
--- /dev/null
+++ b/testsuites/sptests/spatomic07/system.h
@@ -0,0 +1,51 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include "tmacros.h"
+#include "test_support.h"
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Test_task(
+ rtems_task_argument argument
+);
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+);
+/* configuration information */
+#define TASK_NUMS 4
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS \
+ (2 + TASK_NUMS)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+/*
+ * Keep the names and IDs in global variables so another task can use them.
+ */
+
+TEST_EXTERN volatile bool TaskRan[ TASK_NUMS ];
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/* end of include file */
diff --git a/testsuites/sptests/spatomic07/tasks.c b/testsuites/sptests/spatomic07/tasks.c
new file mode 100644
index 0000000000..ff925d0118
--- /dev/null
+++ b/testsuites/sptests/spatomic07/tasks.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2012 Deng Hengyi.
+ *
+ * This test case is to test atomic compare and exchange operation.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#include <stdlib.h>
+#include <rtems/rtems/atomic.h>
+
+#define TEST_REPEAT 200000
+
+#define ATOMIC_CAS_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+{ \
+ Atomic_##TYPE a = 0, b = 0; \
+ 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){ \
+ 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))){ \
+ 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){ \
+ printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": FAILED\n", (unsigned int)task_id); \
+ rtems_test_exit( 0 ); \
+ } \
+ } \
+ printf("\ntask%d: _Atomic_Compare_exchange_" #NAME ": SUCCESS\n", (unsigned int)task_id); \
+}
+
+rtems_task Test_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ rtems_status_code status;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* 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(long, Long, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+
+ /* test acquire barrier */
+ ATOMIC_CAS_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+
+ /* test release barrier */
+ ATOMIC_CAS_NO_BARRIER(int, Int, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(long, Long, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELEASE_BARRIER);
+
+ ATOMIC_CAS_NO_BARRIER(32, Int32, argument, ATOMIC_RELEASE_BARRIER);
+
+ /* Set the flag that the task is up and running */
+ TaskRan[argument] = true;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "delete" );
+}
+
+rtems_task Wait_task(
+ rtems_task_argument argument
+ )
+{
+ char name[5];
+ char *p;
+ bool allDone;
+ int i;
+
+ /* Get the task name */
+ p = rtems_object_get_name( RTEMS_SELF, 5, name );
+ rtems_test_assert( p != NULL );
+
+ /* Wait on the all tasks to run */
+ while (1) {
+ allDone = true;
+ for ( i=0; i<TASK_NUMS ; i++ ) {
+ if (TaskRan[i] == false)
+ allDone = false;
+ }
+ if (allDone) {
+ puts( "\n\n*** END OF TEST spatomic07 ***\n" );
+ rtems_test_exit( 0 );
+ }
+ }
+}