STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
xatomic0.h
Go to the documentation of this file.
1 /* xatomic0.h internal header */
2 #pragma once
3 #ifndef _XATOMIC0_H
4 #define _XATOMIC0_H
5 #ifndef RC_INVOKED
6 #include <yvals.h>
7 
8  #pragma pack(push,_CRT_PACKING)
9  #pragma warning(push,3)
10  #pragma push_macro("new")
11  #undef new
12 
14  #if !defined(_GENERIC_ATOMICS)
15  #define _GENERIC_ATOMICS 0 /* nonzero for (non-conforming) generic */
16  #endif /* !defined(_GENERIC_ATOMICS) */
17 
18  /* ENUM memory_order */
19 typedef enum memory_order {
26  } memory_order;
27 
30 
31  /* SET SIZES AND FLAGS FOR COMPILER AND TARGET ARCHITECTURE */
32  /* Note: the xxx_SIZE macros are used to generate function names,
33  so they must expand to the digits representing
34  the number of bytes in the type; they cannot be expressions
35  that give the number of bytes. */
36 
37  #define _WCHAR_T_SIZE 2
38  #define _SHORT_SIZE 2
39  #define _INT_SIZE 4
40  #define _LONG_SIZE 4
41  #define _LONGLONG_SIZE 8
42 
43  #if defined(_M_X64) || defined(_LP64) || defined(__x86_64)
44  #define _ADDR_SIZE 8
45 
46  #if !_GENERIC_ATOMICS
47  #define _MS_64 1
48  #endif /* !_GENERIC_ATOMICS */
49 
50  #else /* defined(_M_X64) || defined(_LP64) || defined(__x86_64) */
51  #define _ADDR_SIZE 4
52 
53  #if defined(_M_ARM)
54 
55  #elif !_GENERIC_ATOMICS
56  #define _MS_32 1
57  #endif /* !_GENERIC_ATOMICS */
58  #endif /* defined(_M_X64) || defined(_LP64) || defined(__x86_64) */
59 
60  #if !defined(_MS_32)
61  #define _MS_32 0
62  #endif /* !defined(_MS_32) */
63 
64  #if !defined(_MS_64)
65  #define _MS_64 0
66  #endif /* !defined(_MS_64) */
67 
68  /* TYPEDEF _Atomic_flag_t */
69 
70 typedef long _Atomic_flag_t;
71 
72  #define _ATOMIC_MAXBYTES_LOCK_FREE 8
73  #define _ATOMIC_FLAG_USES_LOCK 0
74  #define _ATOMIC_FENCE_USES_LOCK 0
75 
76  /* DECLARATIONS NEEDED FOR ATOMIC REFERENCE COUNTING */
77 inline _Uint4_t _Atomic_load_4(volatile _Uint4_t *, memory_order);
81  volatile _Uint4_t *, _Uint4_t, memory_order);
83  volatile _Uint4_t *, _Uint4_t, memory_order);
84 
86 
87  #if defined(__cplusplus)
88 inline _Atomic_integral_t
89  _Get_atomic_count(const _Atomic_counter_t& _Counter)
90  { // get counter
91  return (_Counter);
92  }
93 
94 inline void _Init_atomic_counter(_Atomic_counter_t& _Counter,
96  { // non-atomically initialize counter
97  _Counter = _Value;
98  }
99 
101  _Atomic_counter_t& _Counter, memory_order _Order)
102  { // atomically increment counter and return result
103  return (_Atomic_fetch_add_4(&_Counter, 1, _Order) + 1);
104  }
105 
107  { // atomically increment counter and return result
109  }
110 
112  _Atomic_counter_t& _Counter, memory_order _Order)
113  { // atomically decrement counter and return result
114  return (_Atomic_fetch_sub_4(&_Counter, 1, _Order) - 1);
115  }
116 
118  { // atomically decrement counter and return result
120  }
121 
123  _Atomic_counter_t& _Counter, memory_order _Order)
124  { // atomically load counter and return result
125  return (_Atomic_load_4(&_Counter, _Order));
126  }
127 
129  { // atomically load counter and return result
131  }
132 
134  _Atomic_counter_t& _Counter,
135  _Atomic_integral_t _Expected,
136  memory_order _Order)
137  { // atomically compare and increment counter and return result
139  &_Counter, &_Expected, _Expected + 1,
140  _Order, _Order));
141  }
142 
144  _Atomic_counter_t& _Counter, _Atomic_integral_t _Expected)
145  { // atomically compare and increment counter and return result
147  _Counter, _Expected, memory_order_seq_cst));
148  }
149 
150  #else /* defined(__cplusplus) */
151 #define _Get_atomic_count(_Counter) _Counter
152 
153 #define _Init_atomic_counter(_Counter, _Value) \
154  _Counter = _Value
155 
156 #define _Inc_atomic_counter_explicit(_Counter, _Order) \
157  (_Atomic_fetch_add_4(&_Counter, 1, _Order) + 1)
158 
159 #define _Inc_atomic_counter(_Counter) \
160  (_Inc_atomic_counter_explicit(_Counter, memory_order_seq_cst))
161 
162 #define _Dec_atomic_counter_explicit(_Counter, _Order) \
163  (_Atomic_fetch_sub_4(&_Counter, 1, _Order) - 1)
164 
165 #define _Dec_atomic_counter(_Counter) \
166  (_Dec_atomic_counter_explicit(_Counter, memory_order_seq_cst))
167 
168 #define _Load_atomic_counter_explicit(_Counter, _Order) \
169  _Atomic_load_4(&_Counter, _Order)
170 
171 #define _Load_atomic_counter(_Counter) \
172  _Load_atomic_counter_explicit(_Counter, memory_order_seq_cst)
173 
174 #define _Compare_increment_atomic_counter_explicit(_Counter, _Expected, _Order) \
175  _Atomic_compare_exchange_weak_4(&_Counter, &_Expected, _Expected + 1, \
176  _Order, _Order)
177 
178 #define _Compare_increment_atomic_counter(_Counter, _Expected) \
179  _Compare_increment_atomic_counter_explicit( \
180  _Counter, _Expected, memory_order_seq_cst)
181  #endif /* defined(__cplusplus) */
182 
183  /* SPIN LOCKS */
184 _EXTERN_C
188 _STD_END
189  #pragma pop_macro("new")
190  #pragma warning(pop)
191  #pragma pack(pop)
192 #endif /* RC_INVOKED */
193 #endif /* _XATOMIC0_H */
194 
195 /*
196  * Copyright (c) 1992-2012 by P.J. Plauger. ALL RIGHTS RESERVED.
197  * Consult your license regarding permissions and restrictions.
198 V6.00:0009 */
#define _Inc_atomic_counter(_Counter)
Definition: xatomic0.h:159
#define _END_EXTERN_C
Definition: yvals.h:564
#define _Load_atomic_counter_explicit(_Counter, _Order)
Definition: xatomic0.h:168
_CRTIMP _In_ int _Value
Definition: setjmp.h:190
#define _STD_BEGIN
Definition: yvals.h:553
#define _Dec_atomic_counter(_Counter)
Definition: xatomic0.h:165
_CRTIMP2_PURE void __cdecl _Unlock_shared_ptr_spin_lock()
unsigned long _Uint32t
Definition: yvals.h:820
_EXTERN_C _CRTIMP2_PURE void __cdecl _Lock_shared_ptr_spin_lock()
_Uint4_t _Atomic_fetch_sub_4(volatile _Uint4_t *, _Uint4_t, memory_order)
Definition: xatomic.h:1693
#define _Inc_atomic_counter_explicit(_Counter, _Order)
Definition: xatomic0.h:156
long _Atomic_flag_t
Definition: xatomic0.h:70
#define _Load_atomic_counter(_Counter)
Definition: xatomic0.h:171
_Uint32t _Uint4_t
Definition: xatomic0.h:28
#define _Get_atomic_count(_Counter)
Definition: xatomic0.h:151
#define _EXTERN_C
Definition: yvals.h:563
_Uint4_t _Atomic_load_4(volatile _Uint4_t *, memory_order)
Definition: xatomic.h:1444
int _Atomic_compare_exchange_weak_4(volatile _Uint4_t *, _Uint4_t *, _Uint4_t, memory_order, memory_order)
Definition: xatomic.h:1629
#define _Compare_increment_atomic_counter(_Counter, _Expected)
Definition: xatomic0.h:178
_Uint4_t _Atomic_integral_t
Definition: xatomic0.h:29
memory_order
Definition: xatomic0.h:19
#define _Compare_increment_atomic_counter_explicit(_Counter, _Expected, _Order)
Definition: xatomic0.h:174
Definition: xatomic0.h:24
#define _Init_atomic_counter(_Counter, _Value)
Definition: xatomic0.h:153
#define _STD_END
Definition: yvals.h:554
Definition: xatomic0.h:21
_Uint4_t _Atomic_fetch_add_4(volatile _Uint4_t *, _Uint4_t, memory_order)
Definition: xatomic.h:1668
Definition: xatomic0.h:20
Definition: xatomic0.h:25
Definition: xatomic0.h:23
Definition: xatomic0.h:22
#define _Dec_atomic_counter_explicit(_Counter, _Order)
Definition: xatomic0.h:162
#define _CRTIMP2_PURE
Definition: yvals.h:483
_Atomic_integral_t _Atomic_counter_t
Definition: xatomic0.h:85