source: rtems/cpukit/score/include/rtems/score/atomic.h @ 89f8eab5

4.115
Last change on this file since 89f8eab5 was 89f8eab5, checked in by Sebastian Huber <sebastian.huber@…>, on 05/07/14 at 12:55:37

score: Workaround for GCC 4.9 for atomic ops

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

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreAtomic
5 *
6 * @brief Atomic Operations API
7 */
8
9/*
10 * COPYRIGHT (c) 2012-2013 Deng Hengyi.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_SCORE_ATOMIC_H
18#define _RTEMS_SCORE_ATOMIC_H
19
20#include <rtems/score/cpuatomic.h>
21
22/**
23 * @defgroup ScoreAtomic Atomic Operations
24 *
25 * @ingroup Score
26 *
27 * @brief Support for atomic operations.
28 *
29 * Atomic operations can be used to implement low-level synchronization
30 * primitives on SMP systems, like spin locks.  All atomic operations are
31 * defined in terms of C11 (ISO/IEC 9899:2011) or C++11 (ISO/IEC 14882:2011).
32 * For documentation use the standard documents.
33 *
34 * @{
35 */
36
37typedef CPU_atomic_Uint Atomic_Uint;
38
39typedef CPU_atomic_Ulong Atomic_Ulong;
40
41typedef CPU_atomic_Pointer Atomic_Pointer;
42
43typedef CPU_atomic_Flag Atomic_Flag;
44
45#define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED
46
47#define ATOMIC_ORDER_ACQUIRE CPU_ATOMIC_ORDER_ACQUIRE
48
49#define ATOMIC_ORDER_RELEASE CPU_ATOMIC_ORDER_RELEASE
50
51#define ATOMIC_ORDER_SEQ_CST CPU_ATOMIC_ORDER_SEQ_CST
52
53#define ATOMIC_INITIALIZER_UINT( value ) CPU_ATOMIC_INITIALIZER_UINT( value )
54
55#define ATOMIC_INITIALIZER_ULONG( value ) CPU_ATOMIC_INITIALIZER_ULONG( value )
56
57#define ATOMIC_INITIALIZER_PTR( value ) CPU_ATOMIC_INITIALIZER_PTR( value )
58
59#define ATOMIC_INITIALIZER_FLAG CPU_ATOMIC_INITIALIZER_FLAG
60
61#define _Atomic_Fence( order ) _CPU_atomic_Fence( order )
62
63#define _Atomic_Init_uint( obj, desired ) \
64  _CPU_atomic_Init_uint( obj, desired )
65
66#define _Atomic_Init_ulong( obj, desired ) \
67  _CPU_atomic_Init_ulong( obj, desired )
68
69#define _Atomic_Init_ptr( obj, desired ) \
70  _CPU_atomic_Init_ptr( obj, desired )
71
72#define _Atomic_Load_uint( obj, order ) \
73  _CPU_atomic_Load_uint( obj, order )
74
75#define _Atomic_Load_ulong( obj, order ) \
76  _CPU_atomic_Load_ulong( obj, order )
77
78#define _Atomic_Load_ptr( obj, order ) \
79  _CPU_atomic_Load_ptr( obj, order )
80
81#define _Atomic_Store_uint( obj, desr, order ) \
82  _CPU_atomic_Store_uint( obj, desr, order )
83
84#define _Atomic_Store_ulong( obj, desr, order ) \
85  _CPU_atomic_Store_ulong( obj, desr, order )
86
87#define _Atomic_Store_ptr( obj, desr, order ) \
88  _CPU_atomic_Store_ptr( obj, desr, order )
89
90#define _Atomic_Fetch_add_uint( obj, arg, order ) \
91  _CPU_atomic_Fetch_add_uint( obj, arg, order )
92
93#define _Atomic_Fetch_add_ulong( obj, arg, order ) \
94  _CPU_atomic_Fetch_add_ulong( obj, arg, order )
95
96#define _Atomic_Fetch_add_ptr( obj, arg, order ) \
97  _CPU_atomic_Fetch_add_ptr( obj, arg, order )
98
99#define _Atomic_Fetch_sub_uint( obj, arg, order ) \
100  _CPU_atomic_Fetch_sub_uint( obj, arg, order )
101
102#define _Atomic_Fetch_sub_ulong( obj, arg, order ) \
103  _CPU_atomic_Fetch_sub_ulong( obj, arg, order )
104
105#define _Atomic_Fetch_sub_ptr( obj, arg, order ) \
106  _CPU_atomic_Fetch_sub_ptr( obj, arg, order )
107
108#define _Atomic_Fetch_or_uint( obj, arg, order ) \
109  _CPU_atomic_Fetch_or_uint( obj, arg, order )
110
111#define _Atomic_Fetch_or_ulong( obj, arg, order ) \
112  _CPU_atomic_Fetch_or_ulong( obj, arg, order )
113
114#define _Atomic_Fetch_or_ptr( obj, arg, order ) \
115  _CPU_atomic_Fetch_or_ptr( obj, arg, order )
116
117#define _Atomic_Fetch_and_uint( obj, arg, order ) \
118  _CPU_atomic_Fetch_and_uint( obj, arg, order )
119
120#define _Atomic_Fetch_and_ulong( obj, arg, order ) \
121  _CPU_atomic_Fetch_and_ulong( obj, arg, order )
122
123#define _Atomic_Fetch_and_ptr( obj, arg, order ) \
124  _CPU_atomic_Fetch_and_ptr( obj, arg, order )
125
126#define _Atomic_Exchange_uint( obj, desr, order ) \
127  _CPU_atomic_Exchange_uint( obj, desr, order )
128
129#define _Atomic_Exchange_ulong( obj, desr, order ) \
130  _CPU_atomic_Exchange_ulong( obj, desr, order )
131
132#define _Atomic_Exchange_ptr( obj, desr, order ) \
133  _CPU_atomic_Exchange_ptr( obj, desr, order )
134
135#define _Atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \
136  _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail )
137
138#define _Atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \
139  _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail )
140
141#define _Atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail ) \
142  _CPU_atomic_Compare_exchange_ptr( obj, expected, desired, succ, fail )
143
144#define _Atomic_Flag_clear( obj, order ) \
145  _CPU_atomic_Flag_clear( obj, order )
146
147#define _Atomic_Flag_test_and_set( obj, order ) \
148  _CPU_atomic_Flag_test_and_set( obj, order )
149
150/** @} */
151
152#endif /* _RTEMS_SCORE_ATOMIC_H */
Note: See TracBrowser for help on using the repository browser.