Index: cpukit/score/Makefile.am
===================================================================
--- cpukit/score/Makefile.am	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ cpukit/score/Makefile.am	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -18,4 +18,5 @@
 include_rtems_score_HEADERS += include/rtems/score/apimutex.h
 include_rtems_score_HEADERS += include/rtems/score/assert.h
+include_rtems_score_HEADERS += include/rtems/score/atomic.h
 include_rtems_score_HEADERS += include/rtems/score/chain.h
 include_rtems_score_HEADERS += include/rtems/score/chainimpl.h
@@ -32,4 +33,5 @@
 include_rtems_score_HEADERS += include/rtems/score/cpuset.h
 include_rtems_score_HEADERS += include/rtems/score/cpusetimpl.h
+include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
 include_rtems_score_HEADERS += include/rtems/score/heap.h
 include_rtems_score_HEADERS += include/rtems/score/heapimpl.h
@@ -113,6 +115,4 @@
 
 if HAS_SMP
-include_rtems_score_HEADERS += include/rtems/score/atomic.h
-include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
 include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmpimpl.h
 include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityaffinitysmp.h
Index: cpukit/score/include/rtems/score/atomic.h
===================================================================
--- cpukit/score/include/rtems/score/atomic.h	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ cpukit/score/include/rtems/score/atomic.h	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -42,4 +42,6 @@
 
 typedef CPU_atomic_Flag Atomic_Flag;
+
+typedef CPU_atomic_Order Atomic_Order;
 
 #define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED
Index: cpukit/score/include/rtems/score/cpustdatomic.h
===================================================================
--- cpukit/score/include/rtems/score/cpustdatomic.h	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ cpukit/score/include/rtems/score/cpustdatomic.h	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -7,4 +7,5 @@
 /*
  * COPYRIGHT (c) 2013 Deng Hengyi.
+ * Copyright (c) 2015 embedded brains GmbH.
  *
  * The license and distribution terms for this file may be
@@ -16,18 +17,27 @@
 #define _RTEMS_SCORE_CPUSTDATOMIC_H
 
-#include <stdint.h>
-
-#if defined(__cplusplus) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 9
-
-/*
- * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible.  The
- * suggested solution was to include <atomic> in case C++ is used.  This works
- * at least with GCC 4.9.  See also:
- *
- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940
- */
-
-#include <atomic>
+#include <rtems/score/basedefs.h>
+
+#ifdef RTEMS_SMP
+  #if defined(__cplusplus) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 9
+    /*
+     * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible.  The
+     * suggested solution was to include <atomic> in case C++ is used.  This works
+     * at least with GCC 4.9.  See also:
+     *
+     * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
+     * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940
+     */
+    #include <atomic>
+    #define _RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC
+  #else
+    #include <stdatomic.h>
+    #define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC
+  #endif
+#else
+  #include <rtems/score/isrlevel.h>
+#endif
+
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
 
 typedef std::atomic_uint CPU_atomic_Uint;
@@ -38,4 +48,6 @@
 
 typedef std::atomic_flag CPU_atomic_Flag;
+
+typedef std::memory_order CPU_atomic_Order;
 
 #define CPU_ATOMIC_ORDER_RELAXED std::memory_order_relaxed
@@ -56,96 +68,5 @@
 #define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
 
-#define _CPU_atomic_Fence( order ) atomic_thread_fence( order )
-
-#define _CPU_atomic_Init_uint( obj, desired ) \
-  (obj)->store( desired )
-
-#define _CPU_atomic_Init_ulong( obj, desired ) \
-  (obj)->store( desired )
-
-#define _CPU_atomic_Init_ptr( obj, desired ) \
-  (obj)->store( desired )
-
-#define _CPU_atomic_Load_uint( obj, order ) \
-  (obj)->load( order )
-
-#define _CPU_atomic_Load_ulong( obj, order ) \
-  (obj)->load( order )
-
-#define _CPU_atomic_Load_ptr( obj, order ) \
-  (void *) (obj)->load( order )
-
-#define _CPU_atomic_Store_uint( obj, desr, order ) \
-  (obj)->store( desr, order )
-
-#define _CPU_atomic_Store_ulong( obj, desr, order ) \
-  (obj)->store( desr, order )
-
-#define _CPU_atomic_Store_ptr( obj, desr, order ) \
-  (obj)->store( (uintptr_t) desr, order )
-
-#define _CPU_atomic_Fetch_add_uint( obj, arg, order ) \
-  (obj)->fetch_add( arg, order )
-
-#define _CPU_atomic_Fetch_add_ulong( obj, arg, order ) \
-  (obj)->fetch_add( arg, order )
-
-#define _CPU_atomic_Fetch_add_ptr( obj, arg, order ) \
-  (obj)->fetch_add( arg, (uintptr_t) order )
-
-#define _CPU_atomic_Fetch_sub_uint( obj, arg, order ) \
-  (obj)->fetch_sub( arg, order )
-
-#define _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) \
-  (obj)->fetch_sub( arg, order )
-
-#define _CPU_atomic_Fetch_sub_ptr( obj, arg, order ) \
-  (obj)->fetch_sub( arg, (uintptr_t) order )
-
-#define _CPU_atomic_Fetch_or_uint( obj, arg, order ) \
-  (obj)->fetch_or( arg, order )
-
-#define _CPU_atomic_Fetch_or_ulong( obj, arg, order ) \
-  (obj)->fetch_or( arg, order )
-
-#define _CPU_atomic_Fetch_or_ptr( obj, arg, order ) \
-  (obj)->fetch_or( arg, (uintptr_t) order )
-
-#define _CPU_atomic_Fetch_and_uint( obj, arg, order ) \
-  (obj)->fetch_and( arg, order )
-
-#define _CPU_atomic_Fetch_and_ulong( obj, arg, order ) \
-  (obj)->fetch_and( arg, order )
-
-#define _CPU_atomic_Fetch_and_ptr( obj, arg, order ) \
-  (obj)->fetch_and( arg, (uintptr_t) order )
-
-#define _CPU_atomic_Exchange_uint( obj, desr, order ) \
-  (obj)->exchange( desr, order )
-
-#define _CPU_atomic_Exchange_ulong( obj, desr, order ) \
-  (obj)->exchange( desr, order )
-
-#define _CPU_atomic_Exchange_ptr( obj, desr, order ) \
-  (void *) (obj)->exchange( desr, (uintptr_t) order )
-
-#define _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
-  (obj)->compare_exchange_strong( expected, desired, succ, fail )
-
-#define _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
-  (obj)->compare_exchange_strong( expected, desired, succ, fail )
-
-#define _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
-  (obj)->compare_exchange_strong( (void **) expected, (uintptr_t) desired, succ, fail )
-
-#define _CPU_atomic_Flag_clear( obj, order ) \
-  (obj)->clear( order )
-
-#define _CPU_atomic_Flag_test_and_set( obj, order ) \
-  (obj)->test_and_set( order )
-
-#else /* __cplusplus */
-
-#include <stdatomic.h>
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
 
 typedef atomic_uint CPU_atomic_Uint;
@@ -156,4 +77,6 @@
 
 typedef atomic_flag CPU_atomic_Flag;
+
+typedef memory_order CPU_atomic_Order;
 
 #define CPU_ATOMIC_ORDER_RELAXED memory_order_relaxed
@@ -174,94 +97,551 @@
 #define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
 
-#define _CPU_atomic_Fence( order ) atomic_thread_fence( order )
-
-#define _CPU_atomic_Init_uint( obj, desired ) \
-  atomic_init( obj, desired )
-
-#define _CPU_atomic_Init_ulong( obj, desired ) \
-  atomic_init( obj, desired )
-
-#define _CPU_atomic_Init_ptr( obj, desired ) \
-  atomic_init( obj, (uintptr_t) desired )
-
-#define _CPU_atomic_Load_uint( obj, order ) \
-  atomic_load_explicit( obj, order )
-
-#define _CPU_atomic_Load_ulong( obj, order ) \
-  atomic_load_explicit( obj, order )
-
-#define _CPU_atomic_Load_ptr( obj, order ) \
-  (void *) atomic_load_explicit( obj, order )
-
-#define _CPU_atomic_Store_uint( obj, desr, order ) \
-  atomic_store_explicit( obj, desr, order )
-
-#define _CPU_atomic_Store_ulong( obj, desr, order ) \
-  atomic_store_explicit( obj, desr, order )
-
-#define _CPU_atomic_Store_ptr( obj, desr, order ) \
-  atomic_store_explicit( obj, desr, order )
-
-#define _CPU_atomic_Fetch_add_uint( obj, arg, order ) \
-  atomic_fetch_add_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_add_ulong( obj, arg, order ) \
-  atomic_fetch_add_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_add_ptr( obj, arg, order ) \
-  atomic_fetch_add_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_sub_uint( obj, arg, order ) \
-  atomic_fetch_sub_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) \
-  atomic_fetch_sub_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_sub_ptr( obj, arg, order ) \
-  atomic_fetch_sub_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_or_uint( obj, arg, order ) \
-  atomic_fetch_or_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_or_ulong( obj, arg, order ) \
-  atomic_fetch_or_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_or_ptr( obj, arg, order ) \
-  atomic_fetch_or_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_and_uint( obj, arg, order ) \
-  atomic_fetch_and_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_and_ulong( obj, arg, order ) \
-  atomic_fetch_and_explicit( obj, arg, order )
-
-#define _CPU_atomic_Fetch_and_ptr( obj, arg, order ) \
-  atomic_fetch_and_explicit( obj, arg, order )
-
-#define _CPU_atomic_Exchange_uint( obj, desr, order ) \
-  atomic_exchange_explicit( obj, desr, order )
-
-#define _CPU_atomic_Exchange_ulong( obj, desr, order ) \
-  atomic_exchange_explicit( obj, desr, order )
-
-#define _CPU_atomic_Exchange_ptr( obj, desr, order ) \
-  atomic_exchange_explicit( obj, desr, order )
-
-#define _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
-  atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
-
-#define _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
-  atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
-
-#define _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
-  atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
-
-#define _CPU_atomic_Flag_clear( obj, order ) \
-  atomic_flag_clear_explicit( obj, order )
-
-#define _CPU_atomic_Flag_test_and_set( obj, order ) \
-  atomic_flag_test_and_set_explicit( obj, order )
-
-#endif /* __cplusplus */
+#else
+
+typedef unsigned int CPU_atomic_Uint;
+
+typedef unsigned long CPU_atomic_Ulong;
+
+typedef uintptr_t CPU_atomic_Pointer;
+
+typedef bool CPU_atomic_Flag;
+
+typedef int CPU_atomic_Order;
+
+#define CPU_ATOMIC_ORDER_RELAXED 0
+
+#define CPU_ATOMIC_ORDER_ACQUIRE 2
+
+#define CPU_ATOMIC_ORDER_RELEASE 3
+
+#define CPU_ATOMIC_ORDER_SEQ_CST 5
+
+#define CPU_ATOMIC_INITIALIZER_UINT( value ) ( value )
+
+#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value )
+
+#define CPU_ATOMIC_INITIALIZER_PTR( value ) ( (uintptr_t) (value) )
+
+#define CPU_ATOMIC_INITIALIZER_FLAG false
+
+#endif
+
+static inline void _CPU_atomic_Fence( CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  std::atomic_thread_fence( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_thread_fence( order );
+#else
+  (void) order;
+  RTEMS_COMPILER_MEMORY_BARRIER();
+#endif
+}
+
+static inline void _CPU_atomic_Init_uint( CPU_atomic_Uint *obj, unsigned int desired )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_init( obj, desired );
+#else
+  *obj = desired;
+#endif
+}
+
+static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long desired )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_init( obj, desired );
+#else
+  *obj = desired;
+#endif
+}
+
+static inline void _CPU_atomic_Init_ptr( CPU_atomic_Pointer *obj, void *desired )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( (uintptr_t) desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_init( obj, (uintptr_t) desired );
+#else
+  *obj = (uintptr_t) desired;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Load_uint( const CPU_atomic_Uint *obj, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->load( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_load_explicit( obj, order );
+#else
+  (void) order;
+  return *obj;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->load( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_load_explicit( obj, order );
+#else
+  (void) order;
+  return *obj;
+#endif
+}
+
+static inline void *_CPU_atomic_Load_ptr( const CPU_atomic_Pointer *obj, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->load( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_load_explicit( obj, order );
+#else
+  (void) order;
+  return (void *) *obj;
+#endif
+}
+
+static inline void _CPU_atomic_Store_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_store_explicit( obj, desired, order );
+#else
+  (void) order;
+  *obj = desired;
+#endif
+}
+
+static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_store_explicit( obj, desired, order );
+#else
+  (void) order;
+  *obj = desired;
+#endif
+}
+
+static inline void _CPU_atomic_Store_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->store( (uintptr_t) desired );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_store_explicit( obj, (uintptr_t) desired, order );
+#else
+  (void) order;
+  *obj = (uintptr_t) desired;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Fetch_add_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_add( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_add_explicit( obj, arg, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val + arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_add( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_add_explicit( obj, arg, order );
+#else
+  unsigned long val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val + arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline void *_CPU_atomic_Fetch_add_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->fetch_add( (uintptr_t) arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_fetch_add_explicit( obj, (uintptr_t) arg, order );
+#else
+  uintptr_t val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val + (uintptr_t) arg;
+  _ISR_Enable( level );
+
+  return (void *) val;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Fetch_sub_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_sub( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_sub_explicit( obj, arg, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val - arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_sub( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_sub_explicit( obj, arg, order );
+#else
+  unsigned long val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val - arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline void *_CPU_atomic_Fetch_sub_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->fetch_sub( (uintptr_t) arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_fetch_sub_explicit( obj, (uintptr_t) arg, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val - (uintptr_t) arg;
+  _ISR_Enable( level );
+
+  return (void *) val;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Fetch_or_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_or( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_or_explicit( obj, arg, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val | arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_or( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_or_explicit( obj, arg, order );
+#else
+  unsigned long val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val | arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline void *_CPU_atomic_Fetch_or_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->fetch_or( (uintptr_t) arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_fetch_or_explicit( obj, (uintptr_t) arg, order );
+#else
+  uintptr_t val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val | (uintptr_t) arg;
+  _ISR_Enable( level );
+
+  return (void *) val;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Fetch_and_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_and( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_and_explicit( obj, arg, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val & arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->fetch_and( arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_fetch_and_explicit( obj, arg, order );
+#else
+  unsigned long val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val & arg;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline void *_CPU_atomic_Fetch_and_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->fetch_and( (uintptr_t) arg, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_fetch_and_explicit( obj, (uintptr_t) arg, order );
+#else
+  uintptr_t val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = val & (uintptr_t) arg;
+  _ISR_Enable( level );
+
+  return (void *) val;
+#endif
+}
+
+static inline unsigned int _CPU_atomic_Exchange_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->exchange( desired, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_exchange_explicit( obj, desired, order );
+#else
+  unsigned int val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = desired;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->exchange( desired, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_exchange_explicit( obj, desired, order );
+#else
+  unsigned long val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = desired;
+  _ISR_Enable( level );
+
+  return val;
+#endif
+}
+
+static inline void *_CPU_atomic_Exchange_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return (void *) obj->exchange( (uintptr_t) desired, order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return (void *) atomic_exchange_explicit( obj, (uintptr_t) desired, order );
+#else
+  uintptr_t val;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  val = *obj;
+  *obj = (uintptr_t) desired;
+  _ISR_Enable( level );
+
+  return (void *) val;
+#endif
+}
+
+static inline bool _CPU_atomic_Compare_exchange_uint( CPU_atomic_Uint *obj, unsigned int *expected, unsigned int desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->compare_exchange_strong( *expected, desired, succ, fail );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail );
+#else
+  bool success;
+  ISR_Level level;
+
+  (void) succ;
+  (void) fail;
+  _ISR_Disable( level );
+  success = *obj == *expected;
+  if ( success ) {
+    *obj = desired;
+  }
+  _ISR_Enable( level );
+
+  return success;
+#endif
+}
+
+static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, unsigned long *expected, unsigned long desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->compare_exchange_strong( *expected, desired, succ, fail );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail );
+#else
+  bool success;
+  ISR_Level level;
+
+  (void) succ;
+  (void) fail;
+  _ISR_Disable( level );
+  success = *obj == *expected;
+  if ( success ) {
+    *obj = desired;
+  }
+  _ISR_Enable( level );
+
+  return success;
+#endif
+}
+
+static inline bool _CPU_atomic_Compare_exchange_ptr( CPU_atomic_Pointer *obj, void **expected, void *desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->compare_exchange_strong( *(uintptr_t *) expected, (uintptr_t) desired, succ, fail );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_compare_exchange_strong_explicit( obj, (uintptr_t *) expected, (uintptr_t) desired, succ, fail );
+#else
+  bool success;
+  ISR_Level level;
+
+  (void) succ;
+  (void) fail;
+  _ISR_Disable( level );
+  success = *obj == (uintptr_t) *expected;
+  if ( success ) {
+    *obj = (uintptr_t) desired;
+  }
+  _ISR_Enable( level );
+
+  return success;
+#endif
+}
+
+static inline void _CPU_atomic_Flag_clear( CPU_atomic_Flag *obj, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  obj->clear( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  atomic_flag_clear_explicit( obj, order );
+#else
+  (void) order;
+  *obj = false;
+#endif
+}
+
+static inline bool _CPU_atomic_Flag_test_and_set( CPU_atomic_Flag *obj, CPU_atomic_Order order )
+{
+#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
+  return obj->test_and_set( order );
+#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
+  return atomic_flag_test_and_set_explicit( obj, order );
+#else
+  bool flag;
+  ISR_Level level;
+
+  (void) order;
+  _ISR_Disable( level );
+  flag = *obj;
+  *obj = true;
+  _ISR_Enable( level );
+
+  return flag;
+#endif
+}
 
 #endif /* _RTEMS_SCORE_CPUSTDATOMIC_H */
Index: cpukit/score/preinstall.am
===================================================================
--- cpukit/score/preinstall.am	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ cpukit/score/preinstall.am	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -52,4 +52,8 @@
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/assert.h
 
+$(PROJECT_INCLUDE)/rtems/score/atomic.h: include/rtems/score/atomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/atomic.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/atomic.h
+
 $(PROJECT_INCLUDE)/rtems/score/chain.h: include/rtems/score/chain.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/chain.h
@@ -107,4 +111,8 @@
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpusetimpl.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpusetimpl.h
+
+$(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h: include/rtems/score/cpustdatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
 
 $(PROJECT_INCLUDE)/rtems/score/heap.h: include/rtems/score/heap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
@@ -399,12 +407,4 @@
 endif
 if HAS_SMP
-$(PROJECT_INCLUDE)/rtems/score/atomic.h: include/rtems/score/atomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/atomic.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/atomic.h
-
-$(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h: include/rtems/score/cpustdatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
-
 $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h: include/rtems/score/schedulerprioritysmpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h
Index: testsuites/smptests/smpatomic01/init.c
===================================================================
--- testsuites/smptests/smpatomic01/init.c	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ testsuites/smptests/smpatomic01/init.c	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -390,53 +390,4 @@
 }
 
-static void test_static_and_dynamic_initialization(void)
-{
-  static Atomic_Uint static_uint =
-    ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
-  static Atomic_Ulong static_ulong =
-    ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
-  static Atomic_Pointer static_ptr =
-    ATOMIC_INITIALIZER_PTR(&static_ptr);
-  static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
-
-  Atomic_Uint stack_uint;
-  Atomic_Ulong stack_ulong;
-  Atomic_Pointer stack_ptr;
-  Atomic_Flag stack_flag;
-
-  puts("=== static and dynamic initialization test case ===");
-
-  _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
-  _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
-  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
-  _Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);
-
-  rtems_test_assert(
-    memcmp(&stack_uint, &static_uint, sizeof(stack_uint)) == 0
-  );
-  rtems_test_assert(
-    memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
-  );
-  rtems_test_assert(
-    memcmp(&stack_ptr, &static_ptr, sizeof(stack_ptr)) == 0
-  );
-  rtems_test_assert(
-    memcmp(&stack_flag, &static_flag, sizeof(stack_flag)) == 0
-  );
-
-  rtems_test_assert(
-    _Atomic_Load_uint(&stack_uint, ATOMIC_ORDER_RELAXED) == 0xc01dc0feU
-  );
-  rtems_test_assert(
-    _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
-  );
-  rtems_test_assert(
-    _Atomic_Load_ptr(&stack_ptr, ATOMIC_ORDER_RELAXED) == &static_ptr
-  );
-  rtems_test_assert(
-    !_Atomic_Flag_test_and_set(&stack_flag, ATOMIC_ORDER_RELAXED)
-  );
-}
-
 static void test(void)
 {
@@ -444,6 +395,4 @@
   rtems_status_code sc;
   size_t worker_index;
-
-  test_static_and_dynamic_initialization();
 
   ctx->worker_count = rtems_get_processor_count();
@@ -475,156 +424,7 @@
 }
 
-typedef void (*simple_test_body)(test_context *ctx);
-
-static void test_simple_atomic_add_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple add test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_add_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == (ia + ib));
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_add_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == (a + b));
-}
-
-static void test_simple_atomic_sub_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple sub test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_sub_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == (ia - ib));
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_sub_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == (a - b));
-}
-
-static void test_simple_atomic_or_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple or test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_or_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == (ia | ib));
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_or_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == (a | b));
-}
-
-static void test_simple_atomic_and_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple and test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_and_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == (ia & ib));
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Fetch_and_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == (a & b));
-}
-
-static void test_simple_atomic_exchange_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple exchange test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Exchange_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == ib);
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Exchange_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == b);
-}
-
-static void test_simple_atomic_compare_exchange_body(test_context *ctx)
-{
-  unsigned int ia = 8, ib = 4;
-  unsigned int ic;
-  unsigned long a = 2, b = 1;
-  unsigned long c;
-
-  puts("=== atomic simple compare exchange test case ===\n");
-
-  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
-  _Atomic_Compare_exchange_uint(&ctx->atomic_int_value, &ia, ib,
-    ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
-  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(ic == ib);
-
-  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
-  _Atomic_Compare_exchange_ulong(&ctx->atomic_value, &a, b,
-    ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
-  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
-  rtems_test_assert(c == b);
-}
-
-static const simple_test_body simple_test_bodies[] = {
-  test_simple_atomic_add_body,
-  test_simple_atomic_sub_body,
-  test_simple_atomic_or_body,
-  test_simple_atomic_and_body,
-  test_simple_atomic_exchange_body,
-  test_simple_atomic_compare_exchange_body,
-};
-
-#define SIMPLE_TEST_COUNT RTEMS_ARRAY_SIZE(simple_test_bodies)
-
-static void simple_tests(void)
-{
-  test_context *ctx = &test_instance;
-  size_t test;
-
-  for (test = 0; test < SIMPLE_TEST_COUNT; ++test) {
-    const simple_test_body *test_body = &simple_test_bodies[test];
-
-    (*test_body)(ctx);
-  }
-}
-
 static void Init(rtems_task_argument arg)
 {
   TEST_BEGIN();
-
-  simple_tests();
 
   test();
Index: testsuites/smptests/smpatomic01/smpatomic01.scn
===================================================================
--- testsuites/smptests/smpatomic01/smpatomic01.scn	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ testsuites/smptests/smpatomic01/smpatomic01.scn	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -1,10 +1,3 @@
 *** TEST SMPATOMIC 1 ***
-=== atomic simple add test case ===
-=== atomic simple sub test case ===
-=== atomic simple or test case ===
-=== atomic simple and test case ===
-=== atomic simple exchange test case ===
-=== atomic simple compare exchange test case ===
-=== static and dynamic initialization test case ====
 === atomic add test case ===
 worker 0 value: 16686
Index: testsuites/sptests/Makefile.am
===================================================================
--- testsuites/sptests/Makefile.am	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ testsuites/sptests/Makefile.am	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -38,4 +38,5 @@
 _SUBDIRS += sp29
 endif
+_SUBDIRS += spatomic01
 _SUBDIRS += spintrcritical22
 _SUBDIRS += spsem03
Index: testsuites/sptests/configure.ac
===================================================================
--- testsuites/sptests/configure.ac	(revision fd144302a5e5d8124cb5107ef1ba02b1502d16b1)
+++ testsuites/sptests/configure.ac	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -41,4 +41,5 @@
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+spatomic01/Makefile
 spglobalcon01/Makefile
 spintrcritical22/Makefile
Index: testsuites/sptests/spatomic01/Makefile.am
===================================================================
--- testsuites/sptests/spatomic01/Makefile.am	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
+++ testsuites/sptests/spatomic01/Makefile.am	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spatomic01
+spatomic01_SOURCES = init.c
+
+dist_rtems_tests_DATA = spatomic01.scn 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
Index: testsuites/sptests/spatomic01/init.c
===================================================================
--- testsuites/sptests/spatomic01/init.c	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
+++ testsuites/sptests/spatomic01/init.c	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * Copyright (c) 2013 Deng Hengyi.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/score/atomic.h>
+#include <stdio.h>
+#include <rtems.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SPATOMIC 1";
+
+typedef struct {
+  Atomic_Uint atomic_int_value;
+  Atomic_Ulong atomic_value;
+} test_context;
+
+static test_context test_instance;
+
+static void test_static_and_dynamic_initialization(void)
+{
+  static Atomic_Uint static_uint =
+    ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
+  static Atomic_Ulong static_ulong =
+    ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
+  static Atomic_Pointer static_ptr =
+    ATOMIC_INITIALIZER_PTR(&static_ptr);
+  static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
+
+  Atomic_Uint stack_uint;
+  Atomic_Ulong stack_ulong;
+  Atomic_Pointer stack_ptr;
+  Atomic_Flag stack_flag;
+
+  puts("=== static and dynamic initialization test case ===");
+
+  _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
+  _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
+  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
+  _Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);
+
+  rtems_test_assert(
+    memcmp(&stack_uint, &static_uint, sizeof(stack_uint)) == 0
+  );
+  rtems_test_assert(
+    memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
+  );
+  rtems_test_assert(
+    memcmp(&stack_ptr, &static_ptr, sizeof(stack_ptr)) == 0
+  );
+  rtems_test_assert(
+    memcmp(&stack_flag, &static_flag, sizeof(stack_flag)) == 0
+  );
+
+  rtems_test_assert(
+    _Atomic_Load_uint(&stack_uint, ATOMIC_ORDER_RELAXED) == 0xc01dc0feU
+  );
+  rtems_test_assert(
+    _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
+  );
+  rtems_test_assert(
+    _Atomic_Load_ptr(&stack_ptr, ATOMIC_ORDER_RELAXED) == &static_ptr
+  );
+  rtems_test_assert(
+    !_Atomic_Flag_test_and_set(&stack_flag, ATOMIC_ORDER_RELAXED)
+  );
+}
+
+typedef void (*simple_test_body)(test_context *ctx);
+
+static void test_simple_atomic_add_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple add test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_add_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == (ia + ib));
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_add_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == (a + b));
+}
+
+static void test_simple_atomic_sub_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple sub test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_sub_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == (ia - ib));
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_sub_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == (a - b));
+}
+
+static void test_simple_atomic_or_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple or test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_or_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == (ia | ib));
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_or_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == (a | b));
+}
+
+static void test_simple_atomic_and_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple and test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_and_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == (ia & ib));
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Fetch_and_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == (a & b));
+}
+
+static void test_simple_atomic_exchange_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple exchange test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Exchange_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == ib);
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Exchange_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == b);
+}
+
+static void test_simple_atomic_compare_exchange_body(test_context *ctx)
+{
+  unsigned int ia = 8, ib = 4;
+  unsigned int ic;
+  unsigned long a = 2, b = 1;
+  unsigned long c;
+
+  puts("=== atomic simple compare exchange test case ===");
+
+  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
+  _Atomic_Compare_exchange_uint(&ctx->atomic_int_value, &ia, ib,
+    ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
+  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(ic == ib);
+
+  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
+  _Atomic_Compare_exchange_ulong(&ctx->atomic_value, &a, b,
+    ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
+  c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
+  rtems_test_assert(c == b);
+}
+
+static const simple_test_body simple_test_bodies[] = {
+  test_simple_atomic_add_body,
+  test_simple_atomic_sub_body,
+  test_simple_atomic_or_body,
+  test_simple_atomic_and_body,
+  test_simple_atomic_exchange_body,
+  test_simple_atomic_compare_exchange_body,
+};
+
+#define SIMPLE_TEST_COUNT RTEMS_ARRAY_SIZE(simple_test_bodies)
+
+static void simple_tests(void)
+{
+  test_context *ctx = &test_instance;
+  size_t test;
+
+  for (test = 0; test < SIMPLE_TEST_COUNT; ++test) {
+    const simple_test_body *test_body = &simple_test_bodies[test];
+
+    (*test_body)(ctx);
+  }
+}
+
+static void Init(rtems_task_argument arg)
+{
+  TEST_BEGIN();
+
+  test_static_and_dynamic_initialization();
+  simple_tests();
+
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
Index: testsuites/sptests/spatomic01/spatomic01.scn
===================================================================
--- testsuites/sptests/spatomic01/spatomic01.scn	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
+++ testsuites/sptests/spatomic01/spatomic01.scn	(revision 4e3d9a4d6c76fba8e31138d503f736405dafc213)
@@ -0,0 +1,9 @@
+*** BEGIN OF TEST SPATOMIC 1 ***
+=== static and dynamic initialization test case ===
+=== atomic simple add test case ===
+=== atomic simple sub test case ===
+=== atomic simple or test case ===
+=== atomic simple and test case ===
+=== atomic simple exchange test case ===
+=== atomic simple compare exchange test case ===
+*** END OF TEST SPATOMIC 1 ***
