Changeset 4e3d9a4d in rtems


Ignore:
Timestamp:
Feb 18, 2015, 4:46:37 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
a3316f47
Parents:
fd14430
git-author:
Sebastian Huber <sebastian.huber@…> (02/18/15 16:46:37)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/19/15 09:05:48)
Message:

score: Make <rtems/score/atomic.h> available

Make <rtems/score/atomic.h> available for all RTEMS configurations. Use
inline functions instead of macros. Use ISR disable/enable on
uni-processor configurations to ensure atomicity.

Update #2273.

Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    rfd14430 r4e3d9a4d  
    1818include_rtems_score_HEADERS += include/rtems/score/apimutex.h
    1919include_rtems_score_HEADERS += include/rtems/score/assert.h
     20include_rtems_score_HEADERS += include/rtems/score/atomic.h
    2021include_rtems_score_HEADERS += include/rtems/score/chain.h
    2122include_rtems_score_HEADERS += include/rtems/score/chainimpl.h
     
    3233include_rtems_score_HEADERS += include/rtems/score/cpuset.h
    3334include_rtems_score_HEADERS += include/rtems/score/cpusetimpl.h
     35include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
    3436include_rtems_score_HEADERS += include/rtems/score/heap.h
    3537include_rtems_score_HEADERS += include/rtems/score/heapimpl.h
     
    113115
    114116if HAS_SMP
    115 include_rtems_score_HEADERS += include/rtems/score/atomic.h
    116 include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
    117117include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmpimpl.h
    118118include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityaffinitysmp.h
  • cpukit/score/include/rtems/score/atomic.h

    rfd14430 r4e3d9a4d  
    4242
    4343typedef CPU_atomic_Flag Atomic_Flag;
     44
     45typedef CPU_atomic_Order Atomic_Order;
    4446
    4547#define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED
  • cpukit/score/include/rtems/score/cpustdatomic.h

    rfd14430 r4e3d9a4d  
    77/*
    88 * COPYRIGHT (c) 2013 Deng Hengyi.
     9 * Copyright (c) 2015 embedded brains GmbH.
    910 *
    1011 * The license and distribution terms for this file may be
     
    1617#define _RTEMS_SCORE_CPUSTDATOMIC_H
    1718
    18 #include <stdint.h>
    19 
    20 #if defined(__cplusplus) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 9
    21 
    22 /*
    23  * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible.  The
    24  * suggested solution was to include <atomic> in case C++ is used.  This works
    25  * at least with GCC 4.9.  See also:
    26  *
    27  * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
    28  * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940
    29  */
    30 
    31 #include <atomic>
     19#include <rtems/score/basedefs.h>
     20
     21#ifdef RTEMS_SMP
     22  #if defined(__cplusplus) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 9
     23    /*
     24     * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible.  The
     25     * suggested solution was to include <atomic> in case C++ is used.  This works
     26     * at least with GCC 4.9.  See also:
     27     *
     28     * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
     29     * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940
     30     */
     31    #include <atomic>
     32    #define _RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC
     33  #else
     34    #include <stdatomic.h>
     35    #define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC
     36  #endif
     37#else
     38  #include <rtems/score/isrlevel.h>
     39#endif
     40
     41#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
    3242
    3343typedef std::atomic_uint CPU_atomic_Uint;
     
    3848
    3949typedef std::atomic_flag CPU_atomic_Flag;
     50
     51typedef std::memory_order CPU_atomic_Order;
    4052
    4153#define CPU_ATOMIC_ORDER_RELAXED std::memory_order_relaxed
     
    5668#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
    5769
    58 #define _CPU_atomic_Fence( order ) atomic_thread_fence( order )
    59 
    60 #define _CPU_atomic_Init_uint( obj, desired ) \
    61   (obj)->store( desired )
    62 
    63 #define _CPU_atomic_Init_ulong( obj, desired ) \
    64   (obj)->store( desired )
    65 
    66 #define _CPU_atomic_Init_ptr( obj, desired ) \
    67   (obj)->store( desired )
    68 
    69 #define _CPU_atomic_Load_uint( obj, order ) \
    70   (obj)->load( order )
    71 
    72 #define _CPU_atomic_Load_ulong( obj, order ) \
    73   (obj)->load( order )
    74 
    75 #define _CPU_atomic_Load_ptr( obj, order ) \
    76   (void *) (obj)->load( order )
    77 
    78 #define _CPU_atomic_Store_uint( obj, desr, order ) \
    79   (obj)->store( desr, order )
    80 
    81 #define _CPU_atomic_Store_ulong( obj, desr, order ) \
    82   (obj)->store( desr, order )
    83 
    84 #define _CPU_atomic_Store_ptr( obj, desr, order ) \
    85   (obj)->store( (uintptr_t) desr, order )
    86 
    87 #define _CPU_atomic_Fetch_add_uint( obj, arg, order ) \
    88   (obj)->fetch_add( arg, order )
    89 
    90 #define _CPU_atomic_Fetch_add_ulong( obj, arg, order ) \
    91   (obj)->fetch_add( arg, order )
    92 
    93 #define _CPU_atomic_Fetch_add_ptr( obj, arg, order ) \
    94   (obj)->fetch_add( arg, (uintptr_t) order )
    95 
    96 #define _CPU_atomic_Fetch_sub_uint( obj, arg, order ) \
    97   (obj)->fetch_sub( arg, order )
    98 
    99 #define _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) \
    100   (obj)->fetch_sub( arg, order )
    101 
    102 #define _CPU_atomic_Fetch_sub_ptr( obj, arg, order ) \
    103   (obj)->fetch_sub( arg, (uintptr_t) order )
    104 
    105 #define _CPU_atomic_Fetch_or_uint( obj, arg, order ) \
    106   (obj)->fetch_or( arg, order )
    107 
    108 #define _CPU_atomic_Fetch_or_ulong( obj, arg, order ) \
    109   (obj)->fetch_or( arg, order )
    110 
    111 #define _CPU_atomic_Fetch_or_ptr( obj, arg, order ) \
    112   (obj)->fetch_or( arg, (uintptr_t) order )
    113 
    114 #define _CPU_atomic_Fetch_and_uint( obj, arg, order ) \
    115   (obj)->fetch_and( arg, order )
    116 
    117 #define _CPU_atomic_Fetch_and_ulong( obj, arg, order ) \
    118   (obj)->fetch_and( arg, order )
    119 
    120 #define _CPU_atomic_Fetch_and_ptr( obj, arg, order ) \
    121   (obj)->fetch_and( arg, (uintptr_t) order )
    122 
    123 #define _CPU_atomic_Exchange_uint( obj, desr, order ) \
    124   (obj)->exchange( desr, order )
    125 
    126 #define _CPU_atomic_Exchange_ulong( obj, desr, order ) \
    127   (obj)->exchange( desr, order )
    128 
    129 #define _CPU_atomic_Exchange_ptr( obj, desr, order ) \
    130   (void *) (obj)->exchange( desr, (uintptr_t) order )
    131 
    132 #define _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
    133   (obj)->compare_exchange_strong( expected, desired, succ, fail )
    134 
    135 #define _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
    136   (obj)->compare_exchange_strong( expected, desired, succ, fail )
    137 
    138 #define _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
    139   (obj)->compare_exchange_strong( (void **) expected, (uintptr_t) desired, succ, fail )
    140 
    141 #define _CPU_atomic_Flag_clear( obj, order ) \
    142   (obj)->clear( order )
    143 
    144 #define _CPU_atomic_Flag_test_and_set( obj, order ) \
    145   (obj)->test_and_set( order )
    146 
    147 #else /* __cplusplus */
    148 
    149 #include <stdatomic.h>
     70#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
    15071
    15172typedef atomic_uint CPU_atomic_Uint;
     
    15677
    15778typedef atomic_flag CPU_atomic_Flag;
     79
     80typedef memory_order CPU_atomic_Order;
    15881
    15982#define CPU_ATOMIC_ORDER_RELAXED memory_order_relaxed
     
    17497#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT
    17598
    176 #define _CPU_atomic_Fence( order ) atomic_thread_fence( order )
    177 
    178 #define _CPU_atomic_Init_uint( obj, desired ) \
    179   atomic_init( obj, desired )
    180 
    181 #define _CPU_atomic_Init_ulong( obj, desired ) \
    182   atomic_init( obj, desired )
    183 
    184 #define _CPU_atomic_Init_ptr( obj, desired ) \
    185   atomic_init( obj, (uintptr_t) desired )
    186 
    187 #define _CPU_atomic_Load_uint( obj, order ) \
    188   atomic_load_explicit( obj, order )
    189 
    190 #define _CPU_atomic_Load_ulong( obj, order ) \
    191   atomic_load_explicit( obj, order )
    192 
    193 #define _CPU_atomic_Load_ptr( obj, order ) \
    194   (void *) atomic_load_explicit( obj, order )
    195 
    196 #define _CPU_atomic_Store_uint( obj, desr, order ) \
    197   atomic_store_explicit( obj, desr, order )
    198 
    199 #define _CPU_atomic_Store_ulong( obj, desr, order ) \
    200   atomic_store_explicit( obj, desr, order )
    201 
    202 #define _CPU_atomic_Store_ptr( obj, desr, order ) \
    203   atomic_store_explicit( obj, desr, order )
    204 
    205 #define _CPU_atomic_Fetch_add_uint( obj, arg, order ) \
    206   atomic_fetch_add_explicit( obj, arg, order )
    207 
    208 #define _CPU_atomic_Fetch_add_ulong( obj, arg, order ) \
    209   atomic_fetch_add_explicit( obj, arg, order )
    210 
    211 #define _CPU_atomic_Fetch_add_ptr( obj, arg, order ) \
    212   atomic_fetch_add_explicit( obj, arg, order )
    213 
    214 #define _CPU_atomic_Fetch_sub_uint( obj, arg, order ) \
    215   atomic_fetch_sub_explicit( obj, arg, order )
    216 
    217 #define _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) \
    218   atomic_fetch_sub_explicit( obj, arg, order )
    219 
    220 #define _CPU_atomic_Fetch_sub_ptr( obj, arg, order ) \
    221   atomic_fetch_sub_explicit( obj, arg, order )
    222 
    223 #define _CPU_atomic_Fetch_or_uint( obj, arg, order ) \
    224   atomic_fetch_or_explicit( obj, arg, order )
    225 
    226 #define _CPU_atomic_Fetch_or_ulong( obj, arg, order ) \
    227   atomic_fetch_or_explicit( obj, arg, order )
    228 
    229 #define _CPU_atomic_Fetch_or_ptr( obj, arg, order ) \
    230   atomic_fetch_or_explicit( obj, arg, order )
    231 
    232 #define _CPU_atomic_Fetch_and_uint( obj, arg, order ) \
    233   atomic_fetch_and_explicit( obj, arg, order )
    234 
    235 #define _CPU_atomic_Fetch_and_ulong( obj, arg, order ) \
    236   atomic_fetch_and_explicit( obj, arg, order )
    237 
    238 #define _CPU_atomic_Fetch_and_ptr( obj, arg, order ) \
    239   atomic_fetch_and_explicit( obj, arg, order )
    240 
    241 #define _CPU_atomic_Exchange_uint( obj, desr, order ) \
    242   atomic_exchange_explicit( obj, desr, order )
    243 
    244 #define _CPU_atomic_Exchange_ulong( obj, desr, order ) \
    245   atomic_exchange_explicit( obj, desr, order )
    246 
    247 #define _CPU_atomic_Exchange_ptr( obj, desr, order ) \
    248   atomic_exchange_explicit( obj, desr, order )
    249 
    250 #define _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
    251   atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
    252 
    253 #define _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
    254   atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
    255 
    256 #define _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
    257   atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail )
    258 
    259 #define _CPU_atomic_Flag_clear( obj, order ) \
    260   atomic_flag_clear_explicit( obj, order )
    261 
    262 #define _CPU_atomic_Flag_test_and_set( obj, order ) \
    263   atomic_flag_test_and_set_explicit( obj, order )
    264 
    265 #endif /* __cplusplus */
     99#else
     100
     101typedef unsigned int CPU_atomic_Uint;
     102
     103typedef unsigned long CPU_atomic_Ulong;
     104
     105typedef uintptr_t CPU_atomic_Pointer;
     106
     107typedef bool CPU_atomic_Flag;
     108
     109typedef int CPU_atomic_Order;
     110
     111#define CPU_ATOMIC_ORDER_RELAXED 0
     112
     113#define CPU_ATOMIC_ORDER_ACQUIRE 2
     114
     115#define CPU_ATOMIC_ORDER_RELEASE 3
     116
     117#define CPU_ATOMIC_ORDER_SEQ_CST 5
     118
     119#define CPU_ATOMIC_INITIALIZER_UINT( value ) ( value )
     120
     121#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value )
     122
     123#define CPU_ATOMIC_INITIALIZER_PTR( value ) ( (uintptr_t) (value) )
     124
     125#define CPU_ATOMIC_INITIALIZER_FLAG false
     126
     127#endif
     128
     129static inline void _CPU_atomic_Fence( CPU_atomic_Order order )
     130{
     131#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     132  std::atomic_thread_fence( order );
     133#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     134  atomic_thread_fence( order );
     135#else
     136  (void) order;
     137  RTEMS_COMPILER_MEMORY_BARRIER();
     138#endif
     139}
     140
     141static inline void _CPU_atomic_Init_uint( CPU_atomic_Uint *obj, unsigned int desired )
     142{
     143#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     144  obj->store( desired );
     145#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     146  atomic_init( obj, desired );
     147#else
     148  *obj = desired;
     149#endif
     150}
     151
     152static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long desired )
     153{
     154#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     155  obj->store( desired );
     156#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     157  atomic_init( obj, desired );
     158#else
     159  *obj = desired;
     160#endif
     161}
     162
     163static inline void _CPU_atomic_Init_ptr( CPU_atomic_Pointer *obj, void *desired )
     164{
     165#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     166  obj->store( (uintptr_t) desired );
     167#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     168  atomic_init( obj, (uintptr_t) desired );
     169#else
     170  *obj = (uintptr_t) desired;
     171#endif
     172}
     173
     174static inline unsigned int _CPU_atomic_Load_uint( const CPU_atomic_Uint *obj, CPU_atomic_Order order )
     175{
     176#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     177  return obj->load( order );
     178#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     179  return atomic_load_explicit( obj, order );
     180#else
     181  (void) order;
     182  return *obj;
     183#endif
     184}
     185
     186static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj, CPU_atomic_Order order )
     187{
     188#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     189  return obj->load( order );
     190#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     191  return atomic_load_explicit( obj, order );
     192#else
     193  (void) order;
     194  return *obj;
     195#endif
     196}
     197
     198static inline void *_CPU_atomic_Load_ptr( const CPU_atomic_Pointer *obj, CPU_atomic_Order order )
     199{
     200#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     201  return (void *) obj->load( order );
     202#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     203  return (void *) atomic_load_explicit( obj, order );
     204#else
     205  (void) order;
     206  return (void *) *obj;
     207#endif
     208}
     209
     210static inline void _CPU_atomic_Store_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order )
     211{
     212#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     213  obj->store( desired );
     214#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     215  atomic_store_explicit( obj, desired, order );
     216#else
     217  (void) order;
     218  *obj = desired;
     219#endif
     220}
     221
     222static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order )
     223{
     224#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     225  obj->store( desired );
     226#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     227  atomic_store_explicit( obj, desired, order );
     228#else
     229  (void) order;
     230  *obj = desired;
     231#endif
     232}
     233
     234static inline void _CPU_atomic_Store_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
     235{
     236#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     237  obj->store( (uintptr_t) desired );
     238#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     239  atomic_store_explicit( obj, (uintptr_t) desired, order );
     240#else
     241  (void) order;
     242  *obj = (uintptr_t) desired;
     243#endif
     244}
     245
     246static inline unsigned int _CPU_atomic_Fetch_add_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
     247{
     248#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     249  return obj->fetch_add( arg, order );
     250#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     251  return atomic_fetch_add_explicit( obj, arg, order );
     252#else
     253  unsigned int val;
     254  ISR_Level level;
     255
     256  (void) order;
     257  _ISR_Disable( level );
     258  val = *obj;
     259  *obj = val + arg;
     260  _ISR_Enable( level );
     261
     262  return val;
     263#endif
     264}
     265
     266static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
     267{
     268#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     269  return obj->fetch_add( arg, order );
     270#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     271  return atomic_fetch_add_explicit( obj, arg, order );
     272#else
     273  unsigned long val;
     274  ISR_Level level;
     275
     276  (void) order;
     277  _ISR_Disable( level );
     278  val = *obj;
     279  *obj = val + arg;
     280  _ISR_Enable( level );
     281
     282  return val;
     283#endif
     284}
     285
     286static inline void *_CPU_atomic_Fetch_add_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
     287{
     288#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     289  return (void *) obj->fetch_add( (uintptr_t) arg, order );
     290#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     291  return (void *) atomic_fetch_add_explicit( obj, (uintptr_t) arg, order );
     292#else
     293  uintptr_t val;
     294  ISR_Level level;
     295
     296  (void) order;
     297  _ISR_Disable( level );
     298  val = *obj;
     299  *obj = val + (uintptr_t) arg;
     300  _ISR_Enable( level );
     301
     302  return (void *) val;
     303#endif
     304}
     305
     306static inline unsigned int _CPU_atomic_Fetch_sub_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
     307{
     308#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     309  return obj->fetch_sub( arg, order );
     310#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     311  return atomic_fetch_sub_explicit( obj, arg, order );
     312#else
     313  unsigned int val;
     314  ISR_Level level;
     315
     316  (void) order;
     317  _ISR_Disable( level );
     318  val = *obj;
     319  *obj = val - arg;
     320  _ISR_Enable( level );
     321
     322  return val;
     323#endif
     324}
     325
     326static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
     327{
     328#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     329  return obj->fetch_sub( arg, order );
     330#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     331  return atomic_fetch_sub_explicit( obj, arg, order );
     332#else
     333  unsigned long val;
     334  ISR_Level level;
     335
     336  (void) order;
     337  _ISR_Disable( level );
     338  val = *obj;
     339  *obj = val - arg;
     340  _ISR_Enable( level );
     341
     342  return val;
     343#endif
     344}
     345
     346static inline void *_CPU_atomic_Fetch_sub_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
     347{
     348#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     349  return (void *) obj->fetch_sub( (uintptr_t) arg, order );
     350#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     351  return (void *) atomic_fetch_sub_explicit( obj, (uintptr_t) arg, order );
     352#else
     353  unsigned int val;
     354  ISR_Level level;
     355
     356  (void) order;
     357  _ISR_Disable( level );
     358  val = *obj;
     359  *obj = val - (uintptr_t) arg;
     360  _ISR_Enable( level );
     361
     362  return (void *) val;
     363#endif
     364}
     365
     366static inline unsigned int _CPU_atomic_Fetch_or_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
     367{
     368#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     369  return obj->fetch_or( arg, order );
     370#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     371  return atomic_fetch_or_explicit( obj, arg, order );
     372#else
     373  unsigned int val;
     374  ISR_Level level;
     375
     376  (void) order;
     377  _ISR_Disable( level );
     378  val = *obj;
     379  *obj = val | arg;
     380  _ISR_Enable( level );
     381
     382  return val;
     383#endif
     384}
     385
     386static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
     387{
     388#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     389  return obj->fetch_or( arg, order );
     390#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     391  return atomic_fetch_or_explicit( obj, arg, order );
     392#else
     393  unsigned long val;
     394  ISR_Level level;
     395
     396  (void) order;
     397  _ISR_Disable( level );
     398  val = *obj;
     399  *obj = val | arg;
     400  _ISR_Enable( level );
     401
     402  return val;
     403#endif
     404}
     405
     406static inline void *_CPU_atomic_Fetch_or_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
     407{
     408#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     409  return (void *) obj->fetch_or( (uintptr_t) arg, order );
     410#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     411  return (void *) atomic_fetch_or_explicit( obj, (uintptr_t) arg, order );
     412#else
     413  uintptr_t val;
     414  ISR_Level level;
     415
     416  (void) order;
     417  _ISR_Disable( level );
     418  val = *obj;
     419  *obj = val | (uintptr_t) arg;
     420  _ISR_Enable( level );
     421
     422  return (void *) val;
     423#endif
     424}
     425
     426static inline unsigned int _CPU_atomic_Fetch_and_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order )
     427{
     428#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     429  return obj->fetch_and( arg, order );
     430#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     431  return atomic_fetch_and_explicit( obj, arg, order );
     432#else
     433  unsigned int val;
     434  ISR_Level level;
     435
     436  (void) order;
     437  _ISR_Disable( level );
     438  val = *obj;
     439  *obj = val & arg;
     440  _ISR_Enable( level );
     441
     442  return val;
     443#endif
     444}
     445
     446static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order )
     447{
     448#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     449  return obj->fetch_and( arg, order );
     450#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     451  return atomic_fetch_and_explicit( obj, arg, order );
     452#else
     453  unsigned long val;
     454  ISR_Level level;
     455
     456  (void) order;
     457  _ISR_Disable( level );
     458  val = *obj;
     459  *obj = val & arg;
     460  _ISR_Enable( level );
     461
     462  return val;
     463#endif
     464}
     465
     466static inline void *_CPU_atomic_Fetch_and_ptr( CPU_atomic_Pointer *obj, void *arg, CPU_atomic_Order order )
     467{
     468#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     469  return (void *) obj->fetch_and( (uintptr_t) arg, order );
     470#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     471  return (void *) atomic_fetch_and_explicit( obj, (uintptr_t) arg, order );
     472#else
     473  uintptr_t val;
     474  ISR_Level level;
     475
     476  (void) order;
     477  _ISR_Disable( level );
     478  val = *obj;
     479  *obj = val & (uintptr_t) arg;
     480  _ISR_Enable( level );
     481
     482  return (void *) val;
     483#endif
     484}
     485
     486static inline unsigned int _CPU_atomic_Exchange_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order )
     487{
     488#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     489  return obj->exchange( desired, order );
     490#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     491  return atomic_exchange_explicit( obj, desired, order );
     492#else
     493  unsigned int val;
     494  ISR_Level level;
     495
     496  (void) order;
     497  _ISR_Disable( level );
     498  val = *obj;
     499  *obj = desired;
     500  _ISR_Enable( level );
     501
     502  return val;
     503#endif
     504}
     505
     506static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order )
     507{
     508#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     509  return obj->exchange( desired, order );
     510#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     511  return atomic_exchange_explicit( obj, desired, order );
     512#else
     513  unsigned long val;
     514  ISR_Level level;
     515
     516  (void) order;
     517  _ISR_Disable( level );
     518  val = *obj;
     519  *obj = desired;
     520  _ISR_Enable( level );
     521
     522  return val;
     523#endif
     524}
     525
     526static inline void *_CPU_atomic_Exchange_ptr( CPU_atomic_Pointer *obj, void *desired, CPU_atomic_Order order )
     527{
     528#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     529  return (void *) obj->exchange( (uintptr_t) desired, order );
     530#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     531  return (void *) atomic_exchange_explicit( obj, (uintptr_t) desired, order );
     532#else
     533  uintptr_t val;
     534  ISR_Level level;
     535
     536  (void) order;
     537  _ISR_Disable( level );
     538  val = *obj;
     539  *obj = (uintptr_t) desired;
     540  _ISR_Enable( level );
     541
     542  return (void *) val;
     543#endif
     544}
     545
     546static 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 )
     547{
     548#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     549  return obj->compare_exchange_strong( *expected, desired, succ, fail );
     550#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     551  return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail );
     552#else
     553  bool success;
     554  ISR_Level level;
     555
     556  (void) succ;
     557  (void) fail;
     558  _ISR_Disable( level );
     559  success = *obj == *expected;
     560  if ( success ) {
     561    *obj = desired;
     562  }
     563  _ISR_Enable( level );
     564
     565  return success;
     566#endif
     567}
     568
     569static 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 )
     570{
     571#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     572  return obj->compare_exchange_strong( *expected, desired, succ, fail );
     573#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     574  return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail );
     575#else
     576  bool success;
     577  ISR_Level level;
     578
     579  (void) succ;
     580  (void) fail;
     581  _ISR_Disable( level );
     582  success = *obj == *expected;
     583  if ( success ) {
     584    *obj = desired;
     585  }
     586  _ISR_Enable( level );
     587
     588  return success;
     589#endif
     590}
     591
     592static inline bool _CPU_atomic_Compare_exchange_ptr( CPU_atomic_Pointer *obj, void **expected, void *desired, CPU_atomic_Order succ, CPU_atomic_Order fail )
     593{
     594#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     595  return obj->compare_exchange_strong( *(uintptr_t *) expected, (uintptr_t) desired, succ, fail );
     596#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     597  return atomic_compare_exchange_strong_explicit( obj, (uintptr_t *) expected, (uintptr_t) desired, succ, fail );
     598#else
     599  bool success;
     600  ISR_Level level;
     601
     602  (void) succ;
     603  (void) fail;
     604  _ISR_Disable( level );
     605  success = *obj == (uintptr_t) *expected;
     606  if ( success ) {
     607    *obj = (uintptr_t) desired;
     608  }
     609  _ISR_Enable( level );
     610
     611  return success;
     612#endif
     613}
     614
     615static inline void _CPU_atomic_Flag_clear( CPU_atomic_Flag *obj, CPU_atomic_Order order )
     616{
     617#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     618  obj->clear( order );
     619#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     620  atomic_flag_clear_explicit( obj, order );
     621#else
     622  (void) order;
     623  *obj = false;
     624#endif
     625}
     626
     627static inline bool _CPU_atomic_Flag_test_and_set( CPU_atomic_Flag *obj, CPU_atomic_Order order )
     628{
     629#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC)
     630  return obj->test_and_set( order );
     631#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC)
     632  return atomic_flag_test_and_set_explicit( obj, order );
     633#else
     634  bool flag;
     635  ISR_Level level;
     636
     637  (void) order;
     638  _ISR_Disable( level );
     639  flag = *obj;
     640  *obj = true;
     641  _ISR_Enable( level );
     642
     643  return flag;
     644#endif
     645}
    266646
    267647#endif /* _RTEMS_SCORE_CPUSTDATOMIC_H */
  • cpukit/score/preinstall.am

    rfd14430 r4e3d9a4d  
    5252PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/assert.h
    5353
     54$(PROJECT_INCLUDE)/rtems/score/atomic.h: include/rtems/score/atomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     55        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/atomic.h
     56PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/atomic.h
     57
    5458$(PROJECT_INCLUDE)/rtems/score/chain.h: include/rtems/score/chain.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    5559        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/chain.h
     
    107111        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpusetimpl.h
    108112PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpusetimpl.h
     113
     114$(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h: include/rtems/score/cpustdatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     115        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
     116PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
    109117
    110118$(PROJECT_INCLUDE)/rtems/score/heap.h: include/rtems/score/heap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     
    399407endif
    400408if HAS_SMP
    401 $(PROJECT_INCLUDE)/rtems/score/atomic.h: include/rtems/score/atomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    402         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/atomic.h
    403 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/atomic.h
    404 
    405 $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h: include/rtems/score/cpustdatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    406         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
    407 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h
    408 
    409409$(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h: include/rtems/score/schedulerprioritysmpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    410410        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h
  • testsuites/smptests/smpatomic01/init.c

    rfd14430 r4e3d9a4d  
    390390}
    391391
    392 static void test_static_and_dynamic_initialization(void)
    393 {
    394   static Atomic_Uint static_uint =
    395     ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
    396   static Atomic_Ulong static_ulong =
    397     ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
    398   static Atomic_Pointer static_ptr =
    399     ATOMIC_INITIALIZER_PTR(&static_ptr);
    400   static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
    401 
    402   Atomic_Uint stack_uint;
    403   Atomic_Ulong stack_ulong;
    404   Atomic_Pointer stack_ptr;
    405   Atomic_Flag stack_flag;
    406 
    407   puts("=== static and dynamic initialization test case ===");
    408 
    409   _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
    410   _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
    411   _Atomic_Init_ptr(&stack_ptr, &static_ptr);
    412   _Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);
    413 
    414   rtems_test_assert(
    415     memcmp(&stack_uint, &static_uint, sizeof(stack_uint)) == 0
    416   );
    417   rtems_test_assert(
    418     memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
    419   );
    420   rtems_test_assert(
    421     memcmp(&stack_ptr, &static_ptr, sizeof(stack_ptr)) == 0
    422   );
    423   rtems_test_assert(
    424     memcmp(&stack_flag, &static_flag, sizeof(stack_flag)) == 0
    425   );
    426 
    427   rtems_test_assert(
    428     _Atomic_Load_uint(&stack_uint, ATOMIC_ORDER_RELAXED) == 0xc01dc0feU
    429   );
    430   rtems_test_assert(
    431     _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
    432   );
    433   rtems_test_assert(
    434     _Atomic_Load_ptr(&stack_ptr, ATOMIC_ORDER_RELAXED) == &static_ptr
    435   );
    436   rtems_test_assert(
    437     !_Atomic_Flag_test_and_set(&stack_flag, ATOMIC_ORDER_RELAXED)
    438   );
    439 }
    440 
    441392static void test(void)
    442393{
     
    444395  rtems_status_code sc;
    445396  size_t worker_index;
    446 
    447   test_static_and_dynamic_initialization();
    448397
    449398  ctx->worker_count = rtems_get_processor_count();
     
    475424}
    476425
    477 typedef void (*simple_test_body)(test_context *ctx);
    478 
    479 static void test_simple_atomic_add_body(test_context *ctx)
    480 {
    481   unsigned int ia = 8, ib = 4;
    482   unsigned int ic;
    483   unsigned long a = 2, b = 1;
    484   unsigned long c;
    485 
    486   puts("=== atomic simple add test case ===\n");
    487 
    488   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    489   _Atomic_Fetch_add_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
    490   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    491   rtems_test_assert(ic == (ia + ib));
    492 
    493   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    494   _Atomic_Fetch_add_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
    495   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    496   rtems_test_assert(c == (a + b));
    497 }
    498 
    499 static void test_simple_atomic_sub_body(test_context *ctx)
    500 {
    501   unsigned int ia = 8, ib = 4;
    502   unsigned int ic;
    503   unsigned long a = 2, b = 1;
    504   unsigned long c;
    505 
    506   puts("=== atomic simple sub test case ===\n");
    507 
    508   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    509   _Atomic_Fetch_sub_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
    510   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    511   rtems_test_assert(ic == (ia - ib));
    512 
    513   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    514   _Atomic_Fetch_sub_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
    515   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    516   rtems_test_assert(c == (a - b));
    517 }
    518 
    519 static void test_simple_atomic_or_body(test_context *ctx)
    520 {
    521   unsigned int ia = 8, ib = 4;
    522   unsigned int ic;
    523   unsigned long a = 2, b = 1;
    524   unsigned long c;
    525 
    526   puts("=== atomic simple or test case ===\n");
    527 
    528   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    529   _Atomic_Fetch_or_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
    530   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    531   rtems_test_assert(ic == (ia | ib));
    532 
    533   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    534   _Atomic_Fetch_or_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
    535   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    536   rtems_test_assert(c == (a | b));
    537 }
    538 
    539 static void test_simple_atomic_and_body(test_context *ctx)
    540 {
    541   unsigned int ia = 8, ib = 4;
    542   unsigned int ic;
    543   unsigned long a = 2, b = 1;
    544   unsigned long c;
    545 
    546   puts("=== atomic simple and test case ===\n");
    547 
    548   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    549   _Atomic_Fetch_and_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
    550   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    551   rtems_test_assert(ic == (ia & ib));
    552 
    553   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    554   _Atomic_Fetch_and_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
    555   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    556   rtems_test_assert(c == (a & b));
    557 }
    558 
    559 static void test_simple_atomic_exchange_body(test_context *ctx)
    560 {
    561   unsigned int ia = 8, ib = 4;
    562   unsigned int ic;
    563   unsigned long a = 2, b = 1;
    564   unsigned long c;
    565 
    566   puts("=== atomic simple exchange test case ===\n");
    567 
    568   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    569   _Atomic_Exchange_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
    570   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    571   rtems_test_assert(ic == ib);
    572 
    573   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    574   _Atomic_Exchange_ulong(&ctx->atomic_value, b, ATOMIC_ORDER_RELAXED);
    575   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    576   rtems_test_assert(c == b);
    577 }
    578 
    579 static void test_simple_atomic_compare_exchange_body(test_context *ctx)
    580 {
    581   unsigned int ia = 8, ib = 4;
    582   unsigned int ic;
    583   unsigned long a = 2, b = 1;
    584   unsigned long c;
    585 
    586   puts("=== atomic simple compare exchange test case ===\n");
    587 
    588   _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
    589   _Atomic_Compare_exchange_uint(&ctx->atomic_int_value, &ia, ib,
    590     ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
    591   ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
    592   rtems_test_assert(ic == ib);
    593 
    594   _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
    595   _Atomic_Compare_exchange_ulong(&ctx->atomic_value, &a, b,
    596     ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
    597   c = _Atomic_Load_ulong(&ctx->atomic_value, ATOMIC_ORDER_RELAXED);
    598   rtems_test_assert(c == b);
    599 }
    600 
    601 static const simple_test_body simple_test_bodies[] = {
    602   test_simple_atomic_add_body,
    603   test_simple_atomic_sub_body,
    604   test_simple_atomic_or_body,
    605   test_simple_atomic_and_body,
    606   test_simple_atomic_exchange_body,
    607   test_simple_atomic_compare_exchange_body,
    608 };
    609 
    610 #define SIMPLE_TEST_COUNT RTEMS_ARRAY_SIZE(simple_test_bodies)
    611 
    612 static void simple_tests(void)
    613 {
    614   test_context *ctx = &test_instance;
    615   size_t test;
    616 
    617   for (test = 0; test < SIMPLE_TEST_COUNT; ++test) {
    618     const simple_test_body *test_body = &simple_test_bodies[test];
    619 
    620     (*test_body)(ctx);
    621   }
    622 }
    623 
    624426static void Init(rtems_task_argument arg)
    625427{
    626428  TEST_BEGIN();
    627 
    628   simple_tests();
    629429
    630430  test();
  • testsuites/smptests/smpatomic01/smpatomic01.scn

    rfd14430 r4e3d9a4d  
    11*** TEST SMPATOMIC 1 ***
    2 === atomic simple add test case ===
    3 === atomic simple sub test case ===
    4 === atomic simple or test case ===
    5 === atomic simple and test case ===
    6 === atomic simple exchange test case ===
    7 === atomic simple compare exchange test case ===
    8 === static and dynamic initialization test case ====
    92=== atomic add test case ===
    103worker 0 value: 16686
  • testsuites/sptests/Makefile.am

    rfd14430 r4e3d9a4d  
    3838_SUBDIRS += sp29
    3939endif
     40_SUBDIRS += spatomic01
    4041_SUBDIRS += spintrcritical22
    4142_SUBDIRS += spsem03
  • testsuites/sptests/configure.ac

    rfd14430 r4e3d9a4d  
    4141# Explicitly list all Makefiles here
    4242AC_CONFIG_FILES([Makefile
     43spatomic01/Makefile
    4344spglobalcon01/Makefile
    4445spintrcritical22/Makefile
Note: See TracChangeset for help on using the changeset viewer.