implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / libatomic_ops / src / atomic_ops / generalize-small.h
1 /*
2  * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22
23 /* char_load */
24 #if defined(AO_HAVE_char_load_acquire) && !defined(AO_HAVE_char_load)
25 # define AO_char_load(addr) AO_char_load_acquire(addr)
26 # define AO_HAVE_char_load
27 #endif
28
29 #if defined(AO_HAVE_char_load_full) && !defined(AO_HAVE_char_load_acquire)
30 # define AO_char_load_acquire(addr) AO_char_load_full(addr)
31 # define AO_HAVE_char_load_acquire
32 #endif
33
34 #if defined(AO_HAVE_char_load_full) && !defined(AO_HAVE_char_load_read)
35 # define AO_char_load_read(addr) AO_char_load_full(addr)
36 # define AO_HAVE_char_load_read
37 #endif
38
39 #if !defined(AO_HAVE_char_load_acquire_read) \
40     && defined(AO_HAVE_char_load_acquire)
41 # define AO_char_load_acquire_read(addr) AO_char_load_acquire(addr)
42 # define AO_HAVE_char_load_acquire_read
43 #endif
44
45 #if defined(AO_HAVE_char_load) && defined(AO_HAVE_nop_full) \
46     && !defined(AO_HAVE_char_load_acquire)
47   AO_INLINE unsigned char
48   AO_char_load_acquire(const volatile unsigned char *addr)
49   {
50     unsigned char result = AO_char_load(addr);
51     /* Acquire barrier would be useless, since the load could be delayed    */
52     /* beyond it.                                                           */
53     AO_nop_full();
54     return result;
55   }
56 # define AO_HAVE_char_load_acquire
57 #endif
58
59 #if defined(AO_HAVE_char_load) && defined(AO_HAVE_nop_read) \
60     && !defined(AO_HAVE_char_load_read)
61   AO_INLINE unsigned char
62   AO_char_load_read(const volatile unsigned char *addr)
63   {
64     unsigned char result = AO_char_load(addr);
65     /* Acquire barrier would be useless, since the load could be delayed    */
66     /* beyond it.                                                           */
67     AO_nop_read();
68     return result;
69   }
70 # define AO_HAVE_char_load_read
71 #endif
72
73 #if defined(AO_HAVE_char_load_acquire) && defined(AO_HAVE_nop_full) \
74     && !defined(AO_HAVE_char_load_full)
75 # define AO_char_load_full(addr) (AO_nop_full(), AO_char_load_acquire(addr))
76 # define AO_HAVE_char_load_full
77 #endif
78
79 #if !defined(AO_HAVE_char_load_acquire_read) \
80     && defined(AO_HAVE_char_load_read)
81 # define AO_char_load_acquire_read(addr) AO_char_load_read(addr)
82 # define AO_HAVE_char_load_acquire_read
83 #endif
84
85 #if defined(AO_HAVE_char_load_acquire_read) && !defined(AO_HAVE_char_load)
86 # define AO_char_load(addr) AO_char_load_acquire_read(addr)
87 # define AO_HAVE_char_load
88 #endif
89
90 #ifdef AO_NO_DD_ORDERING
91 # if defined(AO_HAVE_char_load_acquire_read)
92 #   define AO_char_load_dd_acquire_read(addr) AO_char_load_acquire_read(addr)
93 #   define AO_HAVE_char_load_dd_acquire_read
94 # endif
95 #else
96 # if defined(AO_HAVE_char_load)
97 #   define AO_char_load_dd_acquire_read(addr) AO_char_load(addr)
98 #   define AO_HAVE_char_load_dd_acquire_read
99 # endif
100 #endif /* !AO_NO_DD_ORDERING */
101
102 /* char_store */
103 #if defined(AO_HAVE_char_store_release) && !defined(AO_HAVE_char_store)
104 # define AO_char_store(addr, val) AO_char_store_release(addr,val)
105 # define AO_HAVE_char_store
106 #endif
107
108 #if defined(AO_HAVE_char_store_full) && !defined(AO_HAVE_char_store_release)
109 # define AO_char_store_release(addr,val) AO_char_store_full(addr,val)
110 # define AO_HAVE_char_store_release
111 #endif
112
113 #if defined(AO_HAVE_char_store_full) && !defined(AO_HAVE_char_store_write)
114 # define AO_char_store_write(addr,val) AO_char_store_full(addr,val)
115 # define AO_HAVE_char_store_write
116 #endif
117
118 #if defined(AO_HAVE_char_store_release) \
119     && !defined(AO_HAVE_char_store_release_write)
120 # define AO_char_store_release_write(addr, val) \
121                             AO_char_store_release(addr,val)
122 # define AO_HAVE_char_store_release_write
123 #endif
124
125 #if defined(AO_HAVE_char_store_write) && !defined(AO_HAVE_char_store)
126 # define AO_char_store(addr, val) AO_char_store_write(addr,val)
127 # define AO_HAVE_char_store
128 #endif
129
130 #if defined(AO_HAVE_char_store) && defined(AO_HAVE_nop_full) \
131     && !defined(AO_HAVE_char_store_release)
132 # define AO_char_store_release(addr,val) \
133                                 (AO_nop_full(), AO_char_store(addr,val))
134 # define AO_HAVE_char_store_release
135 #endif
136
137 #if defined(AO_HAVE_nop_write) && defined(AO_HAVE_char_store) \
138     && !defined(AO_HAVE_char_store_write)
139 # define AO_char_store_write(addr, val) \
140                                 (AO_nop_write(), AO_char_store(addr,val))
141 # define AO_HAVE_char_store_write
142 #endif
143
144 #if defined(AO_HAVE_char_store_write) \
145     && !defined(AO_HAVE_char_store_release_write)
146 # define AO_char_store_release_write(addr, val) AO_char_store_write(addr,val)
147 # define AO_HAVE_char_store_release_write
148 #endif
149
150 #if defined(AO_HAVE_char_store_release) && defined(AO_HAVE_nop_full) \
151     && !defined(AO_HAVE_char_store_full)
152 # define AO_char_store_full(addr, val) \
153                         (AO_char_store_release(addr, val), AO_nop_full())
154 # define AO_HAVE_char_store_full
155 #endif
156
157 /* char_fetch_and_add */
158 #if defined(AO_HAVE_char_compare_and_swap_full) \
159     && !defined(AO_HAVE_char_fetch_and_add_full)
160   AO_INLINE unsigned char
161   AO_char_fetch_and_add_full(volatile unsigned char *addr,
162                               unsigned char incr)
163   {
164     unsigned char old;
165     do
166       {
167         old = *addr;
168       }
169     while (!AO_char_compare_and_swap_full(addr, old, old+incr));
170     return old;
171   }
172 # define AO_HAVE_char_fetch_and_add_full
173 #endif
174
175 #if defined(AO_HAVE_char_compare_and_swap_acquire) \
176     && !defined(AO_HAVE_char_fetch_and_add_acquire)
177   AO_INLINE unsigned char
178   AO_char_fetch_and_add_acquire(volatile unsigned char *addr,
179                                  unsigned char incr)
180   {
181     unsigned char old;
182     do
183       {
184         old = *addr;
185       }
186     while (!AO_char_compare_and_swap_acquire(addr, old, old+incr));
187     return old;
188   }
189 # define AO_HAVE_char_fetch_and_add_acquire
190 #endif
191
192 #if defined(AO_HAVE_char_compare_and_swap_release) \
193     && !defined(AO_HAVE_char_fetch_and_add_release)
194   AO_INLINE unsigned char
195   AO_char_fetch_and_add_release(volatile unsigned char *addr,
196                                  unsigned char incr)
197   {
198     unsigned char old;
199     do
200       {
201         old = *addr;
202       }
203     while (!AO_char_compare_and_swap_release(addr, old, old+incr));
204     return old;
205   }
206 # define AO_HAVE_char_fetch_and_add_release
207 #endif
208
209 #if defined(AO_HAVE_char_fetch_and_add_full)
210 # if !defined(AO_HAVE_char_fetch_and_add_release)
211 #   define AO_char_fetch_and_add_release(addr, val) \
212                                 AO_char_fetch_and_add_full(addr, val)
213 #   define AO_HAVE_char_fetch_and_add_release
214 # endif
215 # if !defined(AO_HAVE_char_fetch_and_add_acquire)
216 #   define AO_char_fetch_and_add_acquire(addr, val) \
217                                 AO_char_fetch_and_add_full(addr, val)
218 #   define AO_HAVE_char_fetch_and_add_acquire
219 # endif
220 # if !defined(AO_HAVE_char_fetch_and_add_write)
221 #   define AO_char_fetch_and_add_write(addr, val) \
222                                 AO_char_fetch_and_add_full(addr, val)
223 #   define AO_HAVE_char_fetch_and_add_write
224 # endif
225 # if !defined(AO_HAVE_char_fetch_and_add_read)
226 #   define AO_char_fetch_and_add_read(addr, val) \
227                                 AO_char_fetch_and_add_full(addr, val)
228 #   define AO_HAVE_char_fetch_and_add_read
229 # endif
230 #endif /* AO_HAVE_char_fetch_and_add_full */
231
232 #if !defined(AO_HAVE_char_fetch_and_add) \
233     && defined(AO_HAVE_char_fetch_and_add_release)
234 # define AO_char_fetch_and_add(addr, val) \
235                                 AO_char_fetch_and_add_release(addr, val)
236 # define AO_HAVE_char_fetch_and_add
237 #endif
238 #if !defined(AO_HAVE_char_fetch_and_add) \
239     && defined(AO_HAVE_char_fetch_and_add_acquire)
240 # define AO_char_fetch_and_add(addr, val) \
241                                 AO_char_fetch_and_add_acquire(addr, val)
242 # define AO_HAVE_char_fetch_and_add
243 #endif
244 #if !defined(AO_HAVE_char_fetch_and_add) \
245     && defined(AO_HAVE_char_fetch_and_add_write)
246 # define AO_char_fetch_and_add(addr, val) \
247                                 AO_char_fetch_and_add_write(addr, val)
248 # define AO_HAVE_char_fetch_and_add
249 #endif
250 #if !defined(AO_HAVE_char_fetch_and_add) \
251     && defined(AO_HAVE_char_fetch_and_add_read)
252 # define AO_char_fetch_and_add(addr, val) \
253                                 AO_char_fetch_and_add_read(addr, val)
254 # define AO_HAVE_char_fetch_and_add
255 #endif
256
257 #if defined(AO_HAVE_char_fetch_and_add_acquire) \
258     && defined(AO_HAVE_nop_full) && !defined(AO_HAVE_char_fetch_and_add_full)
259 # define AO_char_fetch_and_add_full(addr, val) \
260                 (AO_nop_full(), AO_char_fetch_and_add_acquire(addr, val))
261 # define AO_HAVE_char_fetch_and_add_full
262 #endif
263
264 #if !defined(AO_HAVE_char_fetch_and_add_release_write) \
265     && defined(AO_HAVE_char_fetch_and_add_write)
266 # define AO_char_fetch_and_add_release_write(addr, val) \
267                                 AO_char_fetch_and_add_write(addr, val)
268 # define AO_HAVE_char_fetch_and_add_release_write
269 #endif
270 #if !defined(AO_HAVE_char_fetch_and_add_release_write) \
271     && defined(AO_HAVE_char_fetch_and_add_release)
272 # define AO_char_fetch_and_add_release_write(addr, val) \
273                                 AO_char_fetch_and_add_release(addr, val)
274 # define AO_HAVE_char_fetch_and_add_release_write
275 #endif
276
277 #if !defined(AO_HAVE_char_fetch_and_add_acquire_read) \
278     && defined(AO_HAVE_char_fetch_and_add_read)
279 # define AO_char_fetch_and_add_acquire_read(addr, val) \
280                                 AO_char_fetch_and_add_read(addr, val)
281 # define AO_HAVE_char_fetch_and_add_acquire_read
282 #endif
283 #if !defined(AO_HAVE_char_fetch_and_add_acquire_read) \
284     && defined(AO_HAVE_char_fetch_and_add_acquire)
285 # define AO_char_fetch_and_add_acquire_read(addr, val) \
286                                 AO_char_fetch_and_add_acquire(addr, val)
287 # define AO_HAVE_char_fetch_and_add_acquire_read
288 #endif
289
290 #ifdef AO_NO_DD_ORDERING
291 # if defined(AO_HAVE_char_fetch_and_add_acquire_read)
292 #   define AO_char_fetch_and_add_dd_acquire_read(addr, val) \
293                                 AO_char_fetch_and_add_acquire_read(addr, val)
294 #   define AO_HAVE_char_fetch_and_add_dd_acquire_read
295 # endif
296 #else
297 # if defined(AO_HAVE_char_fetch_and_add)
298 #   define AO_char_fetch_and_add_dd_acquire_read(addr, val) \
299                                 AO_char_fetch_and_add(addr, val)
300 #   define AO_HAVE_char_fetch_and_add_dd_acquire_read
301 # endif
302 #endif /* !AO_NO_DD_ORDERING */
303
304 /* char_fetch_and_add1 */
305 #if defined(AO_HAVE_char_fetch_and_add_full) \
306     && !defined(AO_HAVE_char_fetch_and_add1_full)
307 # define AO_char_fetch_and_add1_full(addr) \
308                                 AO_char_fetch_and_add_full(addr,1)
309 # define AO_HAVE_char_fetch_and_add1_full
310 #endif
311 #if defined(AO_HAVE_char_fetch_and_add_release) \
312     && !defined(AO_HAVE_char_fetch_and_add1_release)
313 # define AO_char_fetch_and_add1_release(addr) \
314                                 AO_char_fetch_and_add_release(addr,1)
315 # define AO_HAVE_char_fetch_and_add1_release
316 #endif
317 #if defined(AO_HAVE_char_fetch_and_add_acquire) \
318     && !defined(AO_HAVE_char_fetch_and_add1_acquire)
319 # define AO_char_fetch_and_add1_acquire(addr) \
320                                 AO_char_fetch_and_add_acquire(addr,1)
321 # define AO_HAVE_char_fetch_and_add1_acquire
322 #endif
323 #if defined(AO_HAVE_char_fetch_and_add_write) \
324     && !defined(AO_HAVE_char_fetch_and_add1_write)
325 # define AO_char_fetch_and_add1_write(addr) \
326                                 AO_char_fetch_and_add_write(addr,1)
327 # define AO_HAVE_char_fetch_and_add1_write
328 #endif
329 #if defined(AO_HAVE_char_fetch_and_add_read) \
330     && !defined(AO_HAVE_char_fetch_and_add1_read)
331 # define AO_char_fetch_and_add1_read(addr) \
332                                 AO_char_fetch_and_add_read(addr,1)
333 # define AO_HAVE_char_fetch_and_add1_read
334 #endif
335 #if defined(AO_HAVE_char_fetch_and_add_release_write) \
336     && !defined(AO_HAVE_char_fetch_and_add1_release_write)
337 # define AO_char_fetch_and_add1_release_write(addr) \
338                                 AO_char_fetch_and_add_release_write(addr,1)
339 # define AO_HAVE_char_fetch_and_add1_release_write
340 #endif
341 #if defined(AO_HAVE_char_fetch_and_add_acquire_read) \
342     && !defined(AO_HAVE_char_fetch_and_add1_acquire_read)
343 # define AO_char_fetch_and_add1_acquire_read(addr) \
344                                 AO_char_fetch_and_add_acquire_read(addr,1)
345 # define AO_HAVE_char_fetch_and_add1_acquire_read
346 #endif
347 #if defined(AO_HAVE_char_fetch_and_add) \
348     && !defined(AO_HAVE_char_fetch_and_add1)
349 # define AO_char_fetch_and_add1(addr) AO_char_fetch_and_add(addr,1)
350 # define AO_HAVE_char_fetch_and_add1
351 #endif
352
353 #if defined(AO_HAVE_char_fetch_and_add1_full)
354 # if !defined(AO_HAVE_char_fetch_and_add1_release)
355 #   define AO_char_fetch_and_add1_release(addr) \
356                                 AO_char_fetch_and_add1_full(addr)
357 #   define AO_HAVE_char_fetch_and_add1_release
358 # endif
359 # if !defined(AO_HAVE_char_fetch_and_add1_acquire)
360 #   define AO_char_fetch_and_add1_acquire(addr) \
361                                 AO_char_fetch_and_add1_full(addr)
362 #   define AO_HAVE_char_fetch_and_add1_acquire
363 # endif
364 # if !defined(AO_HAVE_char_fetch_and_add1_write)
365 #   define AO_char_fetch_and_add1_write(addr) \
366                                 AO_char_fetch_and_add1_full(addr)
367 #   define AO_HAVE_char_fetch_and_add1_write
368 # endif
369 # if !defined(AO_HAVE_char_fetch_and_add1_read)
370 #   define AO_char_fetch_and_add1_read(addr) \
371                                 AO_char_fetch_and_add1_full(addr)
372 #   define AO_HAVE_char_fetch_and_add1_read
373 # endif
374 #endif /* AO_HAVE_char_fetch_and_add1_full */
375
376 #if !defined(AO_HAVE_char_fetch_and_add1) \
377     && defined(AO_HAVE_char_fetch_and_add1_release)
378 # define AO_char_fetch_and_add1(addr) AO_char_fetch_and_add1_release(addr)
379 # define AO_HAVE_char_fetch_and_add1
380 #endif
381 #if !defined(AO_HAVE_char_fetch_and_add1) \
382     && defined(AO_HAVE_char_fetch_and_add1_acquire)
383 # define AO_char_fetch_and_add1(addr) AO_char_fetch_and_add1_acquire(addr)
384 # define AO_HAVE_char_fetch_and_add1
385 #endif
386 #if !defined(AO_HAVE_char_fetch_and_add1) \
387     && defined(AO_HAVE_char_fetch_and_add1_write)
388 # define AO_char_fetch_and_add1(addr) AO_char_fetch_and_add1_write(addr)
389 # define AO_HAVE_char_fetch_and_add1
390 #endif
391 #if !defined(AO_HAVE_char_fetch_and_add1) \
392     && defined(AO_HAVE_char_fetch_and_add1_read)
393 # define AO_char_fetch_and_add1(addr) AO_char_fetch_and_add1_read(addr)
394 # define AO_HAVE_char_fetch_and_add1
395 #endif
396
397 #if defined(AO_HAVE_char_fetch_and_add1_acquire) \
398     && defined(AO_HAVE_nop_full) \
399     && !defined(AO_HAVE_char_fetch_and_add1_full)
400 # define AO_char_fetch_and_add1_full(addr) \
401                         (AO_nop_full(), AO_char_fetch_and_add1_acquire(addr))
402 # define AO_HAVE_char_fetch_and_add1_full
403 #endif
404
405 #if !defined(AO_HAVE_char_fetch_and_add1_release_write) \
406     && defined(AO_HAVE_char_fetch_and_add1_write)
407 # define AO_char_fetch_and_add1_release_write(addr) \
408                                 AO_char_fetch_and_add1_write(addr)
409 # define AO_HAVE_char_fetch_and_add1_release_write
410 #endif
411 #if !defined(AO_HAVE_char_fetch_and_add1_release_write) \
412     && defined(AO_HAVE_char_fetch_and_add1_release)
413 # define AO_char_fetch_and_add1_release_write(addr) \
414                                 AO_char_fetch_and_add1_release(addr)
415 # define AO_HAVE_char_fetch_and_add1_release_write
416 #endif
417 #if !defined(AO_HAVE_char_fetch_and_add1_acquire_read) \
418     && defined(AO_HAVE_char_fetch_and_add1_read)
419 # define AO_char_fetch_and_add1_acquire_read(addr) \
420                                 AO_char_fetch_and_add1_read(addr)
421 # define AO_HAVE_char_fetch_and_add1_acquire_read
422 #endif
423 #if !defined(AO_HAVE_char_fetch_and_add1_acquire_read) \
424     && defined(AO_HAVE_char_fetch_and_add1_acquire)
425 # define AO_char_fetch_and_add1_acquire_read(addr) \
426                                 AO_char_fetch_and_add1_acquire(addr)
427 # define AO_HAVE_char_fetch_and_add1_acquire_read
428 #endif
429
430 #ifdef AO_NO_DD_ORDERING
431 # if defined(AO_HAVE_char_fetch_and_add1_acquire_read)
432 #   define AO_char_fetch_and_add1_dd_acquire_read(addr) \
433                                 AO_char_fetch_and_add1_acquire_read(addr)
434 #   define AO_HAVE_char_fetch_and_add1_dd_acquire_read
435 # endif
436 #else
437 # if defined(AO_HAVE_char_fetch_and_add1)
438 #   define AO_char_fetch_and_add1_dd_acquire_read(addr) \
439                                 AO_char_fetch_and_add1(addr)
440 #   define AO_HAVE_char_fetch_and_add1_dd_acquire_read
441 # endif
442 #endif /* !AO_NO_DD_ORDERING */
443
444 /* char_fetch_and_sub1 */
445 #if defined(AO_HAVE_char_fetch_and_add_full) \
446     && !defined(AO_HAVE_char_fetch_and_sub1_full)
447 # define AO_char_fetch_and_sub1_full(addr) \
448                 AO_char_fetch_and_add_full(addr,(unsigned char)(-1))
449 # define AO_HAVE_char_fetch_and_sub1_full
450 #endif
451 #if defined(AO_HAVE_char_fetch_and_add_release) \
452     && !defined(AO_HAVE_char_fetch_and_sub1_release)
453 # define AO_char_fetch_and_sub1_release(addr) \
454                 AO_char_fetch_and_add_release(addr,(unsigned char)(-1))
455 # define AO_HAVE_char_fetch_and_sub1_release
456 #endif
457 #if defined(AO_HAVE_char_fetch_and_add_acquire) \
458     && !defined(AO_HAVE_char_fetch_and_sub1_acquire)
459 # define AO_char_fetch_and_sub1_acquire(addr) \
460                 AO_char_fetch_and_add_acquire(addr,(unsigned char)(-1))
461 # define AO_HAVE_char_fetch_and_sub1_acquire
462 #endif
463 #if defined(AO_HAVE_char_fetch_and_add_write) \
464     && !defined(AO_HAVE_char_fetch_and_sub1_write)
465 # define AO_char_fetch_and_sub1_write(addr) \
466                 AO_char_fetch_and_add_write(addr,(unsigned char)(-1))
467 # define AO_HAVE_char_fetch_and_sub1_write
468 #endif
469 #if defined(AO_HAVE_char_fetch_and_add_read) \
470     && !defined(AO_HAVE_char_fetch_and_sub1_read)
471 # define AO_char_fetch_and_sub1_read(addr) \
472                 AO_char_fetch_and_add_read(addr,(unsigned char)(-1))
473 # define AO_HAVE_char_fetch_and_sub1_read
474 #endif
475 #if defined(AO_HAVE_char_fetch_and_add_release_write) \
476     && !defined(AO_HAVE_char_fetch_and_sub1_release_write)
477 # define AO_char_fetch_and_sub1_release_write(addr) \
478         AO_char_fetch_and_add_release_write(addr,(unsigned char)(-1))
479 # define AO_HAVE_char_fetch_and_sub1_release_write
480 #endif
481 #if defined(AO_HAVE_char_fetch_and_add_acquire_read) \
482     && !defined(AO_HAVE_char_fetch_and_sub1_acquire_read)
483 # define AO_char_fetch_and_sub1_acquire_read(addr) \
484         AO_char_fetch_and_add_acquire_read(addr,(unsigned char)(-1))
485 # define AO_HAVE_char_fetch_and_sub1_acquire_read
486 #endif
487 #if defined(AO_HAVE_char_fetch_and_add) \
488     && !defined(AO_HAVE_char_fetch_and_sub1)
489 # define AO_char_fetch_and_sub1(addr) \
490                 AO_char_fetch_and_add(addr,(unsigned char)(-1))
491 # define AO_HAVE_char_fetch_and_sub1
492 #endif
493
494 #if defined(AO_HAVE_char_fetch_and_sub1_full)
495 # if !defined(AO_HAVE_char_fetch_and_sub1_release)
496 #   define AO_char_fetch_and_sub1_release(addr) \
497                                 AO_char_fetch_and_sub1_full(addr)
498 #   define AO_HAVE_char_fetch_and_sub1_release
499 # endif
500 # if !defined(AO_HAVE_char_fetch_and_sub1_acquire)
501 #   define AO_char_fetch_and_sub1_acquire(addr) \
502                                 AO_char_fetch_and_sub1_full(addr)
503 #   define AO_HAVE_char_fetch_and_sub1_acquire
504 # endif
505 # if !defined(AO_HAVE_char_fetch_and_sub1_write)
506 #   define AO_char_fetch_and_sub1_write(addr) \
507                                 AO_char_fetch_and_sub1_full(addr)
508 #   define AO_HAVE_char_fetch_and_sub1_write
509 # endif
510 # if !defined(AO_HAVE_char_fetch_and_sub1_read)
511 #   define AO_char_fetch_and_sub1_read(addr) \
512                                 AO_char_fetch_and_sub1_full(addr)
513 #   define AO_HAVE_char_fetch_and_sub1_read
514 # endif
515 #endif /* AO_HAVE_char_fetch_and_sub1_full */
516
517 #if !defined(AO_HAVE_char_fetch_and_sub1) \
518     && defined(AO_HAVE_char_fetch_and_sub1_release)
519 # define AO_char_fetch_and_sub1(addr) AO_char_fetch_and_sub1_release(addr)
520 # define AO_HAVE_char_fetch_and_sub1
521 #endif
522 #if !defined(AO_HAVE_char_fetch_and_sub1) \
523     && defined(AO_HAVE_char_fetch_and_sub1_acquire)
524 # define AO_char_fetch_and_sub1(addr) AO_char_fetch_and_sub1_acquire(addr)
525 # define AO_HAVE_char_fetch_and_sub1
526 #endif
527 #if !defined(AO_HAVE_char_fetch_and_sub1) \
528     && defined(AO_HAVE_char_fetch_and_sub1_write)
529 # define AO_char_fetch_and_sub1(addr) AO_char_fetch_and_sub1_write(addr)
530 # define AO_HAVE_char_fetch_and_sub1
531 #endif
532 #if !defined(AO_HAVE_char_fetch_and_sub1) \
533     && defined(AO_HAVE_char_fetch_and_sub1_read)
534 # define AO_char_fetch_and_sub1(addr) AO_char_fetch_and_sub1_read(addr)
535 # define AO_HAVE_char_fetch_and_sub1
536 #endif
537
538 #if defined(AO_HAVE_char_fetch_and_sub1_acquire) \
539     && defined(AO_HAVE_nop_full) \
540     && !defined(AO_HAVE_char_fetch_and_sub1_full)
541 # define AO_char_fetch_and_sub1_full(addr) \
542                         (AO_nop_full(), AO_char_fetch_and_sub1_acquire(addr))
543 # define AO_HAVE_char_fetch_and_sub1_full
544 #endif
545
546 #if !defined(AO_HAVE_char_fetch_and_sub1_release_write) \
547     && defined(AO_HAVE_char_fetch_and_sub1_write)
548 # define AO_char_fetch_and_sub1_release_write(addr) \
549                                 AO_char_fetch_and_sub1_write(addr)
550 # define AO_HAVE_char_fetch_and_sub1_release_write
551 #endif
552 #if !defined(AO_HAVE_char_fetch_and_sub1_release_write) \
553     && defined(AO_HAVE_char_fetch_and_sub1_release)
554 # define AO_char_fetch_and_sub1_release_write(addr) \
555                                 AO_char_fetch_and_sub1_release(addr)
556 # define AO_HAVE_char_fetch_and_sub1_release_write
557 #endif
558 #if !defined(AO_HAVE_char_fetch_and_sub1_acquire_read) \
559     && defined(AO_HAVE_char_fetch_and_sub1_read)
560 # define AO_char_fetch_and_sub1_acquire_read(addr) \
561                                 AO_char_fetch_and_sub1_read(addr)
562 # define AO_HAVE_char_fetch_and_sub1_acquire_read
563 #endif
564 #if !defined(AO_HAVE_char_fetch_and_sub1_acquire_read) \
565     && defined(AO_HAVE_char_fetch_and_sub1_acquire)
566 # define AO_char_fetch_and_sub1_acquire_read(addr) \
567                                 AO_char_fetch_and_sub1_acquire(addr)
568 # define AO_HAVE_char_fetch_and_sub1_acquire_read
569 #endif
570
571 #ifdef AO_NO_DD_ORDERING
572 # if defined(AO_HAVE_char_fetch_and_sub1_acquire_read)
573 #   define AO_char_fetch_and_sub1_dd_acquire_read(addr) \
574                                 AO_char_fetch_and_sub1_acquire_read(addr)
575 #   define AO_HAVE_char_fetch_and_sub1_dd_acquire_read
576 # endif
577 #else
578 # if defined(AO_HAVE_char_fetch_and_sub1)
579 #   define AO_char_fetch_and_sub1_dd_acquire_read(addr) \
580                                 AO_char_fetch_and_sub1(addr)
581 #   define AO_HAVE_char_fetch_and_sub1_dd_acquire_read
582 # endif
583 #endif /* !AO_NO_DD_ORDERING */
584 /*
585  * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
586  *
587  * Permission is hereby granted, free of charge, to any person obtaining a copy
588  * of this software and associated documentation files (the "Software"), to deal
589  * in the Software without restriction, including without limitation the rights
590  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
591  * copies of the Software, and to permit persons to whom the Software is
592  * furnished to do so, subject to the following conditions:
593  *
594  * The above copyright notice and this permission notice shall be included in
595  * all copies or substantial portions of the Software.
596  *
597  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
598  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
599  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
600  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
601  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
602  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
603  * SOFTWARE.
604  */
605
606 /* short_load */
607 #if defined(AO_HAVE_short_load_acquire) && !defined(AO_HAVE_short_load)
608 # define AO_short_load(addr) AO_short_load_acquire(addr)
609 # define AO_HAVE_short_load
610 #endif
611
612 #if defined(AO_HAVE_short_load_full) && !defined(AO_HAVE_short_load_acquire)
613 # define AO_short_load_acquire(addr) AO_short_load_full(addr)
614 # define AO_HAVE_short_load_acquire
615 #endif
616
617 #if defined(AO_HAVE_short_load_full) && !defined(AO_HAVE_short_load_read)
618 # define AO_short_load_read(addr) AO_short_load_full(addr)
619 # define AO_HAVE_short_load_read
620 #endif
621
622 #if !defined(AO_HAVE_short_load_acquire_read) \
623     && defined(AO_HAVE_short_load_acquire)
624 # define AO_short_load_acquire_read(addr) AO_short_load_acquire(addr)
625 # define AO_HAVE_short_load_acquire_read
626 #endif
627
628 #if defined(AO_HAVE_short_load) && defined(AO_HAVE_nop_full) \
629     && !defined(AO_HAVE_short_load_acquire)
630   AO_INLINE unsigned short
631   AO_short_load_acquire(const volatile unsigned short *addr)
632   {
633     unsigned short result = AO_short_load(addr);
634     /* Acquire barrier would be useless, since the load could be delayed    */
635     /* beyond it.                                                           */
636     AO_nop_full();
637     return result;
638   }
639 # define AO_HAVE_short_load_acquire
640 #endif
641
642 #if defined(AO_HAVE_short_load) && defined(AO_HAVE_nop_read) \
643     && !defined(AO_HAVE_short_load_read)
644   AO_INLINE unsigned short
645   AO_short_load_read(const volatile unsigned short *addr)
646   {
647     unsigned short result = AO_short_load(addr);
648     /* Acquire barrier would be useless, since the load could be delayed    */
649     /* beyond it.                                                           */
650     AO_nop_read();
651     return result;
652   }
653 # define AO_HAVE_short_load_read
654 #endif
655
656 #if defined(AO_HAVE_short_load_acquire) && defined(AO_HAVE_nop_full) \
657     && !defined(AO_HAVE_short_load_full)
658 # define AO_short_load_full(addr) (AO_nop_full(), AO_short_load_acquire(addr))
659 # define AO_HAVE_short_load_full
660 #endif
661
662 #if !defined(AO_HAVE_short_load_acquire_read) \
663     && defined(AO_HAVE_short_load_read)
664 # define AO_short_load_acquire_read(addr) AO_short_load_read(addr)
665 # define AO_HAVE_short_load_acquire_read
666 #endif
667
668 #if defined(AO_HAVE_short_load_acquire_read) && !defined(AO_HAVE_short_load)
669 # define AO_short_load(addr) AO_short_load_acquire_read(addr)
670 # define AO_HAVE_short_load
671 #endif
672
673 #ifdef AO_NO_DD_ORDERING
674 # if defined(AO_HAVE_short_load_acquire_read)
675 #   define AO_short_load_dd_acquire_read(addr) AO_short_load_acquire_read(addr)
676 #   define AO_HAVE_short_load_dd_acquire_read
677 # endif
678 #else
679 # if defined(AO_HAVE_short_load)
680 #   define AO_short_load_dd_acquire_read(addr) AO_short_load(addr)
681 #   define AO_HAVE_short_load_dd_acquire_read
682 # endif
683 #endif /* !AO_NO_DD_ORDERING */
684
685 /* short_store */
686 #if defined(AO_HAVE_short_store_release) && !defined(AO_HAVE_short_store)
687 # define AO_short_store(addr, val) AO_short_store_release(addr,val)
688 # define AO_HAVE_short_store
689 #endif
690
691 #if defined(AO_HAVE_short_store_full) && !defined(AO_HAVE_short_store_release)
692 # define AO_short_store_release(addr,val) AO_short_store_full(addr,val)
693 # define AO_HAVE_short_store_release
694 #endif
695
696 #if defined(AO_HAVE_short_store_full) && !defined(AO_HAVE_short_store_write)
697 # define AO_short_store_write(addr,val) AO_short_store_full(addr,val)
698 # define AO_HAVE_short_store_write
699 #endif
700
701 #if defined(AO_HAVE_short_store_release) \
702     && !defined(AO_HAVE_short_store_release_write)
703 # define AO_short_store_release_write(addr, val) \
704                             AO_short_store_release(addr,val)
705 # define AO_HAVE_short_store_release_write
706 #endif
707
708 #if defined(AO_HAVE_short_store_write) && !defined(AO_HAVE_short_store)
709 # define AO_short_store(addr, val) AO_short_store_write(addr,val)
710 # define AO_HAVE_short_store
711 #endif
712
713 #if defined(AO_HAVE_short_store) && defined(AO_HAVE_nop_full) \
714     && !defined(AO_HAVE_short_store_release)
715 # define AO_short_store_release(addr,val) \
716                                 (AO_nop_full(), AO_short_store(addr,val))
717 # define AO_HAVE_short_store_release
718 #endif
719
720 #if defined(AO_HAVE_nop_write) && defined(AO_HAVE_short_store) \
721     && !defined(AO_HAVE_short_store_write)
722 # define AO_short_store_write(addr, val) \
723                                 (AO_nop_write(), AO_short_store(addr,val))
724 # define AO_HAVE_short_store_write
725 #endif
726
727 #if defined(AO_HAVE_short_store_write) \
728     && !defined(AO_HAVE_short_store_release_write)
729 # define AO_short_store_release_write(addr, val) AO_short_store_write(addr,val)
730 # define AO_HAVE_short_store_release_write
731 #endif
732
733 #if defined(AO_HAVE_short_store_release) && defined(AO_HAVE_nop_full) \
734     && !defined(AO_HAVE_short_store_full)
735 # define AO_short_store_full(addr, val) \
736                         (AO_short_store_release(addr, val), AO_nop_full())
737 # define AO_HAVE_short_store_full
738 #endif
739
740 /* short_fetch_and_add */
741 #if defined(AO_HAVE_short_compare_and_swap_full) \
742     && !defined(AO_HAVE_short_fetch_and_add_full)
743   AO_INLINE unsigned short
744   AO_short_fetch_and_add_full(volatile unsigned short *addr,
745                               unsigned short incr)
746   {
747     unsigned short old;
748     do
749       {
750         old = *addr;
751       }
752     while (!AO_short_compare_and_swap_full(addr, old, old+incr));
753     return old;
754   }
755 # define AO_HAVE_short_fetch_and_add_full
756 #endif
757
758 #if defined(AO_HAVE_short_compare_and_swap_acquire) \
759     && !defined(AO_HAVE_short_fetch_and_add_acquire)
760   AO_INLINE unsigned short
761   AO_short_fetch_and_add_acquire(volatile unsigned short *addr,
762                                  unsigned short incr)
763   {
764     unsigned short old;
765     do
766       {
767         old = *addr;
768       }
769     while (!AO_short_compare_and_swap_acquire(addr, old, old+incr));
770     return old;
771   }
772 # define AO_HAVE_short_fetch_and_add_acquire
773 #endif
774
775 #if defined(AO_HAVE_short_compare_and_swap_release) \
776     && !defined(AO_HAVE_short_fetch_and_add_release)
777   AO_INLINE unsigned short
778   AO_short_fetch_and_add_release(volatile unsigned short *addr,
779                                  unsigned short incr)
780   {
781     unsigned short old;
782     do
783       {
784         old = *addr;
785       }
786     while (!AO_short_compare_and_swap_release(addr, old, old+incr));
787     return old;
788   }
789 # define AO_HAVE_short_fetch_and_add_release
790 #endif
791
792 #if defined(AO_HAVE_short_fetch_and_add_full)
793 # if !defined(AO_HAVE_short_fetch_and_add_release)
794 #   define AO_short_fetch_and_add_release(addr, val) \
795                                 AO_short_fetch_and_add_full(addr, val)
796 #   define AO_HAVE_short_fetch_and_add_release
797 # endif
798 # if !defined(AO_HAVE_short_fetch_and_add_acquire)
799 #   define AO_short_fetch_and_add_acquire(addr, val) \
800                                 AO_short_fetch_and_add_full(addr, val)
801 #   define AO_HAVE_short_fetch_and_add_acquire
802 # endif
803 # if !defined(AO_HAVE_short_fetch_and_add_write)
804 #   define AO_short_fetch_and_add_write(addr, val) \
805                                 AO_short_fetch_and_add_full(addr, val)
806 #   define AO_HAVE_short_fetch_and_add_write
807 # endif
808 # if !defined(AO_HAVE_short_fetch_and_add_read)
809 #   define AO_short_fetch_and_add_read(addr, val) \
810                                 AO_short_fetch_and_add_full(addr, val)
811 #   define AO_HAVE_short_fetch_and_add_read
812 # endif
813 #endif /* AO_HAVE_short_fetch_and_add_full */
814
815 #if !defined(AO_HAVE_short_fetch_and_add) \
816     && defined(AO_HAVE_short_fetch_and_add_release)
817 # define AO_short_fetch_and_add(addr, val) \
818                                 AO_short_fetch_and_add_release(addr, val)
819 # define AO_HAVE_short_fetch_and_add
820 #endif
821 #if !defined(AO_HAVE_short_fetch_and_add) \
822     && defined(AO_HAVE_short_fetch_and_add_acquire)
823 # define AO_short_fetch_and_add(addr, val) \
824                                 AO_short_fetch_and_add_acquire(addr, val)
825 # define AO_HAVE_short_fetch_and_add
826 #endif
827 #if !defined(AO_HAVE_short_fetch_and_add) \
828     && defined(AO_HAVE_short_fetch_and_add_write)
829 # define AO_short_fetch_and_add(addr, val) \
830                                 AO_short_fetch_and_add_write(addr, val)
831 # define AO_HAVE_short_fetch_and_add
832 #endif
833 #if !defined(AO_HAVE_short_fetch_and_add) \
834     && defined(AO_HAVE_short_fetch_and_add_read)
835 # define AO_short_fetch_and_add(addr, val) \
836                                 AO_short_fetch_and_add_read(addr, val)
837 # define AO_HAVE_short_fetch_and_add
838 #endif
839
840 #if defined(AO_HAVE_short_fetch_and_add_acquire) \
841     && defined(AO_HAVE_nop_full) && !defined(AO_HAVE_short_fetch_and_add_full)
842 # define AO_short_fetch_and_add_full(addr, val) \
843                 (AO_nop_full(), AO_short_fetch_and_add_acquire(addr, val))
844 # define AO_HAVE_short_fetch_and_add_full
845 #endif
846
847 #if !defined(AO_HAVE_short_fetch_and_add_release_write) \
848     && defined(AO_HAVE_short_fetch_and_add_write)
849 # define AO_short_fetch_and_add_release_write(addr, val) \
850                                 AO_short_fetch_and_add_write(addr, val)
851 # define AO_HAVE_short_fetch_and_add_release_write
852 #endif
853 #if !defined(AO_HAVE_short_fetch_and_add_release_write) \
854     && defined(AO_HAVE_short_fetch_and_add_release)
855 # define AO_short_fetch_and_add_release_write(addr, val) \
856                                 AO_short_fetch_and_add_release(addr, val)
857 # define AO_HAVE_short_fetch_and_add_release_write
858 #endif
859
860 #if !defined(AO_HAVE_short_fetch_and_add_acquire_read) \
861     && defined(AO_HAVE_short_fetch_and_add_read)
862 # define AO_short_fetch_and_add_acquire_read(addr, val) \
863                                 AO_short_fetch_and_add_read(addr, val)
864 # define AO_HAVE_short_fetch_and_add_acquire_read
865 #endif
866 #if !defined(AO_HAVE_short_fetch_and_add_acquire_read) \
867     && defined(AO_HAVE_short_fetch_and_add_acquire)
868 # define AO_short_fetch_and_add_acquire_read(addr, val) \
869                                 AO_short_fetch_and_add_acquire(addr, val)
870 # define AO_HAVE_short_fetch_and_add_acquire_read
871 #endif
872
873 #ifdef AO_NO_DD_ORDERING
874 # if defined(AO_HAVE_short_fetch_and_add_acquire_read)
875 #   define AO_short_fetch_and_add_dd_acquire_read(addr, val) \
876                                 AO_short_fetch_and_add_acquire_read(addr, val)
877 #   define AO_HAVE_short_fetch_and_add_dd_acquire_read
878 # endif
879 #else
880 # if defined(AO_HAVE_short_fetch_and_add)
881 #   define AO_short_fetch_and_add_dd_acquire_read(addr, val) \
882                                 AO_short_fetch_and_add(addr, val)
883 #   define AO_HAVE_short_fetch_and_add_dd_acquire_read
884 # endif
885 #endif /* !AO_NO_DD_ORDERING */
886
887 /* short_fetch_and_add1 */
888 #if defined(AO_HAVE_short_fetch_and_add_full) \
889     && !defined(AO_HAVE_short_fetch_and_add1_full)
890 # define AO_short_fetch_and_add1_full(addr) \
891                                 AO_short_fetch_and_add_full(addr,1)
892 # define AO_HAVE_short_fetch_and_add1_full
893 #endif
894 #if defined(AO_HAVE_short_fetch_and_add_release) \
895     && !defined(AO_HAVE_short_fetch_and_add1_release)
896 # define AO_short_fetch_and_add1_release(addr) \
897                                 AO_short_fetch_and_add_release(addr,1)
898 # define AO_HAVE_short_fetch_and_add1_release
899 #endif
900 #if defined(AO_HAVE_short_fetch_and_add_acquire) \
901     && !defined(AO_HAVE_short_fetch_and_add1_acquire)
902 # define AO_short_fetch_and_add1_acquire(addr) \
903                                 AO_short_fetch_and_add_acquire(addr,1)
904 # define AO_HAVE_short_fetch_and_add1_acquire
905 #endif
906 #if defined(AO_HAVE_short_fetch_and_add_write) \
907     && !defined(AO_HAVE_short_fetch_and_add1_write)
908 # define AO_short_fetch_and_add1_write(addr) \
909                                 AO_short_fetch_and_add_write(addr,1)
910 # define AO_HAVE_short_fetch_and_add1_write
911 #endif
912 #if defined(AO_HAVE_short_fetch_and_add_read) \
913     && !defined(AO_HAVE_short_fetch_and_add1_read)
914 # define AO_short_fetch_and_add1_read(addr) \
915                                 AO_short_fetch_and_add_read(addr,1)
916 # define AO_HAVE_short_fetch_and_add1_read
917 #endif
918 #if defined(AO_HAVE_short_fetch_and_add_release_write) \
919     && !defined(AO_HAVE_short_fetch_and_add1_release_write)
920 # define AO_short_fetch_and_add1_release_write(addr) \
921                                 AO_short_fetch_and_add_release_write(addr,1)
922 # define AO_HAVE_short_fetch_and_add1_release_write
923 #endif
924 #if defined(AO_HAVE_short_fetch_and_add_acquire_read) \
925     && !defined(AO_HAVE_short_fetch_and_add1_acquire_read)
926 # define AO_short_fetch_and_add1_acquire_read(addr) \
927                                 AO_short_fetch_and_add_acquire_read(addr,1)
928 # define AO_HAVE_short_fetch_and_add1_acquire_read
929 #endif
930 #if defined(AO_HAVE_short_fetch_and_add) \
931     && !defined(AO_HAVE_short_fetch_and_add1)
932 # define AO_short_fetch_and_add1(addr) AO_short_fetch_and_add(addr,1)
933 # define AO_HAVE_short_fetch_and_add1
934 #endif
935
936 #if defined(AO_HAVE_short_fetch_and_add1_full)
937 # if !defined(AO_HAVE_short_fetch_and_add1_release)
938 #   define AO_short_fetch_and_add1_release(addr) \
939                                 AO_short_fetch_and_add1_full(addr)
940 #   define AO_HAVE_short_fetch_and_add1_release
941 # endif
942 # if !defined(AO_HAVE_short_fetch_and_add1_acquire)
943 #   define AO_short_fetch_and_add1_acquire(addr) \
944                                 AO_short_fetch_and_add1_full(addr)
945 #   define AO_HAVE_short_fetch_and_add1_acquire
946 # endif
947 # if !defined(AO_HAVE_short_fetch_and_add1_write)
948 #   define AO_short_fetch_and_add1_write(addr) \
949                                 AO_short_fetch_and_add1_full(addr)
950 #   define AO_HAVE_short_fetch_and_add1_write
951 # endif
952 # if !defined(AO_HAVE_short_fetch_and_add1_read)
953 #   define AO_short_fetch_and_add1_read(addr) \
954                                 AO_short_fetch_and_add1_full(addr)
955 #   define AO_HAVE_short_fetch_and_add1_read
956 # endif
957 #endif /* AO_HAVE_short_fetch_and_add1_full */
958
959 #if !defined(AO_HAVE_short_fetch_and_add1) \
960     && defined(AO_HAVE_short_fetch_and_add1_release)
961 # define AO_short_fetch_and_add1(addr) AO_short_fetch_and_add1_release(addr)
962 # define AO_HAVE_short_fetch_and_add1
963 #endif
964 #if !defined(AO_HAVE_short_fetch_and_add1) \
965     && defined(AO_HAVE_short_fetch_and_add1_acquire)
966 # define AO_short_fetch_and_add1(addr) AO_short_fetch_and_add1_acquire(addr)
967 # define AO_HAVE_short_fetch_and_add1
968 #endif
969 #if !defined(AO_HAVE_short_fetch_and_add1) \
970     && defined(AO_HAVE_short_fetch_and_add1_write)
971 # define AO_short_fetch_and_add1(addr) AO_short_fetch_and_add1_write(addr)
972 # define AO_HAVE_short_fetch_and_add1
973 #endif
974 #if !defined(AO_HAVE_short_fetch_and_add1) \
975     && defined(AO_HAVE_short_fetch_and_add1_read)
976 # define AO_short_fetch_and_add1(addr) AO_short_fetch_and_add1_read(addr)
977 # define AO_HAVE_short_fetch_and_add1
978 #endif
979
980 #if defined(AO_HAVE_short_fetch_and_add1_acquire) \
981     && defined(AO_HAVE_nop_full) \
982     && !defined(AO_HAVE_short_fetch_and_add1_full)
983 # define AO_short_fetch_and_add1_full(addr) \
984                         (AO_nop_full(), AO_short_fetch_and_add1_acquire(addr))
985 # define AO_HAVE_short_fetch_and_add1_full
986 #endif
987
988 #if !defined(AO_HAVE_short_fetch_and_add1_release_write) \
989     && defined(AO_HAVE_short_fetch_and_add1_write)
990 # define AO_short_fetch_and_add1_release_write(addr) \
991                                 AO_short_fetch_and_add1_write(addr)
992 # define AO_HAVE_short_fetch_and_add1_release_write
993 #endif
994 #if !defined(AO_HAVE_short_fetch_and_add1_release_write) \
995     && defined(AO_HAVE_short_fetch_and_add1_release)
996 # define AO_short_fetch_and_add1_release_write(addr) \
997                                 AO_short_fetch_and_add1_release(addr)
998 # define AO_HAVE_short_fetch_and_add1_release_write
999 #endif
1000 #if !defined(AO_HAVE_short_fetch_and_add1_acquire_read) \
1001     && defined(AO_HAVE_short_fetch_and_add1_read)
1002 # define AO_short_fetch_and_add1_acquire_read(addr) \
1003                                 AO_short_fetch_and_add1_read(addr)
1004 # define AO_HAVE_short_fetch_and_add1_acquire_read
1005 #endif
1006 #if !defined(AO_HAVE_short_fetch_and_add1_acquire_read) \
1007     && defined(AO_HAVE_short_fetch_and_add1_acquire)
1008 # define AO_short_fetch_and_add1_acquire_read(addr) \
1009                                 AO_short_fetch_and_add1_acquire(addr)
1010 # define AO_HAVE_short_fetch_and_add1_acquire_read
1011 #endif
1012
1013 #ifdef AO_NO_DD_ORDERING
1014 # if defined(AO_HAVE_short_fetch_and_add1_acquire_read)
1015 #   define AO_short_fetch_and_add1_dd_acquire_read(addr) \
1016                                 AO_short_fetch_and_add1_acquire_read(addr)
1017 #   define AO_HAVE_short_fetch_and_add1_dd_acquire_read
1018 # endif
1019 #else
1020 # if defined(AO_HAVE_short_fetch_and_add1)
1021 #   define AO_short_fetch_and_add1_dd_acquire_read(addr) \
1022                                 AO_short_fetch_and_add1(addr)
1023 #   define AO_HAVE_short_fetch_and_add1_dd_acquire_read
1024 # endif
1025 #endif /* !AO_NO_DD_ORDERING */
1026
1027 /* short_fetch_and_sub1 */
1028 #if defined(AO_HAVE_short_fetch_and_add_full) \
1029     && !defined(AO_HAVE_short_fetch_and_sub1_full)
1030 # define AO_short_fetch_and_sub1_full(addr) \
1031                 AO_short_fetch_and_add_full(addr,(unsigned short)(-1))
1032 # define AO_HAVE_short_fetch_and_sub1_full
1033 #endif
1034 #if defined(AO_HAVE_short_fetch_and_add_release) \
1035     && !defined(AO_HAVE_short_fetch_and_sub1_release)
1036 # define AO_short_fetch_and_sub1_release(addr) \
1037                 AO_short_fetch_and_add_release(addr,(unsigned short)(-1))
1038 # define AO_HAVE_short_fetch_and_sub1_release
1039 #endif
1040 #if defined(AO_HAVE_short_fetch_and_add_acquire) \
1041     && !defined(AO_HAVE_short_fetch_and_sub1_acquire)
1042 # define AO_short_fetch_and_sub1_acquire(addr) \
1043                 AO_short_fetch_and_add_acquire(addr,(unsigned short)(-1))
1044 # define AO_HAVE_short_fetch_and_sub1_acquire
1045 #endif
1046 #if defined(AO_HAVE_short_fetch_and_add_write) \
1047     && !defined(AO_HAVE_short_fetch_and_sub1_write)
1048 # define AO_short_fetch_and_sub1_write(addr) \
1049                 AO_short_fetch_and_add_write(addr,(unsigned short)(-1))
1050 # define AO_HAVE_short_fetch_and_sub1_write
1051 #endif
1052 #if defined(AO_HAVE_short_fetch_and_add_read) \
1053     && !defined(AO_HAVE_short_fetch_and_sub1_read)
1054 # define AO_short_fetch_and_sub1_read(addr) \
1055                 AO_short_fetch_and_add_read(addr,(unsigned short)(-1))
1056 # define AO_HAVE_short_fetch_and_sub1_read
1057 #endif
1058 #if defined(AO_HAVE_short_fetch_and_add_release_write) \
1059     && !defined(AO_HAVE_short_fetch_and_sub1_release_write)
1060 # define AO_short_fetch_and_sub1_release_write(addr) \
1061         AO_short_fetch_and_add_release_write(addr,(unsigned short)(-1))
1062 # define AO_HAVE_short_fetch_and_sub1_release_write
1063 #endif
1064 #if defined(AO_HAVE_short_fetch_and_add_acquire_read) \
1065     && !defined(AO_HAVE_short_fetch_and_sub1_acquire_read)
1066 # define AO_short_fetch_and_sub1_acquire_read(addr) \
1067         AO_short_fetch_and_add_acquire_read(addr,(unsigned short)(-1))
1068 # define AO_HAVE_short_fetch_and_sub1_acquire_read
1069 #endif
1070 #if defined(AO_HAVE_short_fetch_and_add) \
1071     && !defined(AO_HAVE_short_fetch_and_sub1)
1072 # define AO_short_fetch_and_sub1(addr) \
1073                 AO_short_fetch_and_add(addr,(unsigned short)(-1))
1074 # define AO_HAVE_short_fetch_and_sub1
1075 #endif
1076
1077 #if defined(AO_HAVE_short_fetch_and_sub1_full)
1078 # if !defined(AO_HAVE_short_fetch_and_sub1_release)
1079 #   define AO_short_fetch_and_sub1_release(addr) \
1080                                 AO_short_fetch_and_sub1_full(addr)
1081 #   define AO_HAVE_short_fetch_and_sub1_release
1082 # endif
1083 # if !defined(AO_HAVE_short_fetch_and_sub1_acquire)
1084 #   define AO_short_fetch_and_sub1_acquire(addr) \
1085                                 AO_short_fetch_and_sub1_full(addr)
1086 #   define AO_HAVE_short_fetch_and_sub1_acquire
1087 # endif
1088 # if !defined(AO_HAVE_short_fetch_and_sub1_write)
1089 #   define AO_short_fetch_and_sub1_write(addr) \
1090                                 AO_short_fetch_and_sub1_full(addr)
1091 #   define AO_HAVE_short_fetch_and_sub1_write
1092 # endif
1093 # if !defined(AO_HAVE_short_fetch_and_sub1_read)
1094 #   define AO_short_fetch_and_sub1_read(addr) \
1095                                 AO_short_fetch_and_sub1_full(addr)
1096 #   define AO_HAVE_short_fetch_and_sub1_read
1097 # endif
1098 #endif /* AO_HAVE_short_fetch_and_sub1_full */
1099
1100 #if !defined(AO_HAVE_short_fetch_and_sub1) \
1101     && defined(AO_HAVE_short_fetch_and_sub1_release)
1102 # define AO_short_fetch_and_sub1(addr) AO_short_fetch_and_sub1_release(addr)
1103 # define AO_HAVE_short_fetch_and_sub1
1104 #endif
1105 #if !defined(AO_HAVE_short_fetch_and_sub1) \
1106     && defined(AO_HAVE_short_fetch_and_sub1_acquire)
1107 # define AO_short_fetch_and_sub1(addr) AO_short_fetch_and_sub1_acquire(addr)
1108 # define AO_HAVE_short_fetch_and_sub1
1109 #endif
1110 #if !defined(AO_HAVE_short_fetch_and_sub1) \
1111     && defined(AO_HAVE_short_fetch_and_sub1_write)
1112 # define AO_short_fetch_and_sub1(addr) AO_short_fetch_and_sub1_write(addr)
1113 # define AO_HAVE_short_fetch_and_sub1
1114 #endif
1115 #if !defined(AO_HAVE_short_fetch_and_sub1) \
1116     && defined(AO_HAVE_short_fetch_and_sub1_read)
1117 # define AO_short_fetch_and_sub1(addr) AO_short_fetch_and_sub1_read(addr)
1118 # define AO_HAVE_short_fetch_and_sub1
1119 #endif
1120
1121 #if defined(AO_HAVE_short_fetch_and_sub1_acquire) \
1122     && defined(AO_HAVE_nop_full) \
1123     && !defined(AO_HAVE_short_fetch_and_sub1_full)
1124 # define AO_short_fetch_and_sub1_full(addr) \
1125                         (AO_nop_full(), AO_short_fetch_and_sub1_acquire(addr))
1126 # define AO_HAVE_short_fetch_and_sub1_full
1127 #endif
1128
1129 #if !defined(AO_HAVE_short_fetch_and_sub1_release_write) \
1130     && defined(AO_HAVE_short_fetch_and_sub1_write)
1131 # define AO_short_fetch_and_sub1_release_write(addr) \
1132                                 AO_short_fetch_and_sub1_write(addr)
1133 # define AO_HAVE_short_fetch_and_sub1_release_write
1134 #endif
1135 #if !defined(AO_HAVE_short_fetch_and_sub1_release_write) \
1136     && defined(AO_HAVE_short_fetch_and_sub1_release)
1137 # define AO_short_fetch_and_sub1_release_write(addr) \
1138                                 AO_short_fetch_and_sub1_release(addr)
1139 # define AO_HAVE_short_fetch_and_sub1_release_write
1140 #endif
1141 #if !defined(AO_HAVE_short_fetch_and_sub1_acquire_read) \
1142     && defined(AO_HAVE_short_fetch_and_sub1_read)
1143 # define AO_short_fetch_and_sub1_acquire_read(addr) \
1144                                 AO_short_fetch_and_sub1_read(addr)
1145 # define AO_HAVE_short_fetch_and_sub1_acquire_read
1146 #endif
1147 #if !defined(AO_HAVE_short_fetch_and_sub1_acquire_read) \
1148     && defined(AO_HAVE_short_fetch_and_sub1_acquire)
1149 # define AO_short_fetch_and_sub1_acquire_read(addr) \
1150                                 AO_short_fetch_and_sub1_acquire(addr)
1151 # define AO_HAVE_short_fetch_and_sub1_acquire_read
1152 #endif
1153
1154 #ifdef AO_NO_DD_ORDERING
1155 # if defined(AO_HAVE_short_fetch_and_sub1_acquire_read)
1156 #   define AO_short_fetch_and_sub1_dd_acquire_read(addr) \
1157                                 AO_short_fetch_and_sub1_acquire_read(addr)
1158 #   define AO_HAVE_short_fetch_and_sub1_dd_acquire_read
1159 # endif
1160 #else
1161 # if defined(AO_HAVE_short_fetch_and_sub1)
1162 #   define AO_short_fetch_and_sub1_dd_acquire_read(addr) \
1163                                 AO_short_fetch_and_sub1(addr)
1164 #   define AO_HAVE_short_fetch_and_sub1_dd_acquire_read
1165 # endif
1166 #endif /* !AO_NO_DD_ORDERING */
1167 /*
1168  * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
1169  *
1170  * Permission is hereby granted, free of charge, to any person obtaining a copy
1171  * of this software and associated documentation files (the "Software"), to deal
1172  * in the Software without restriction, including without limitation the rights
1173  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1174  * copies of the Software, and to permit persons to whom the Software is
1175  * furnished to do so, subject to the following conditions:
1176  *
1177  * The above copyright notice and this permission notice shall be included in
1178  * all copies or substantial portions of the Software.
1179  *
1180  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1181  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1182  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1183  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1184  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1185  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1186  * SOFTWARE.
1187  */
1188
1189 /* int_load */
1190 #if defined(AO_HAVE_int_load_acquire) && !defined(AO_HAVE_int_load)
1191 # define AO_int_load(addr) AO_int_load_acquire(addr)
1192 # define AO_HAVE_int_load
1193 #endif
1194
1195 #if defined(AO_HAVE_int_load_full) && !defined(AO_HAVE_int_load_acquire)
1196 # define AO_int_load_acquire(addr) AO_int_load_full(addr)
1197 # define AO_HAVE_int_load_acquire
1198 #endif
1199
1200 #if defined(AO_HAVE_int_load_full) && !defined(AO_HAVE_int_load_read)
1201 # define AO_int_load_read(addr) AO_int_load_full(addr)
1202 # define AO_HAVE_int_load_read
1203 #endif
1204
1205 #if !defined(AO_HAVE_int_load_acquire_read) \
1206     && defined(AO_HAVE_int_load_acquire)
1207 # define AO_int_load_acquire_read(addr) AO_int_load_acquire(addr)
1208 # define AO_HAVE_int_load_acquire_read
1209 #endif
1210
1211 #if defined(AO_HAVE_int_load) && defined(AO_HAVE_nop_full) \
1212     && !defined(AO_HAVE_int_load_acquire)
1213   AO_INLINE unsigned int
1214   AO_int_load_acquire(const volatile unsigned int *addr)
1215   {
1216     unsigned int result = AO_int_load(addr);
1217     /* Acquire barrier would be useless, since the load could be delayed    */
1218     /* beyond it.                                                           */
1219     AO_nop_full();
1220     return result;
1221   }
1222 # define AO_HAVE_int_load_acquire
1223 #endif
1224
1225 #if defined(AO_HAVE_int_load) && defined(AO_HAVE_nop_read) \
1226     && !defined(AO_HAVE_int_load_read)
1227   AO_INLINE unsigned int
1228   AO_int_load_read(const volatile unsigned int *addr)
1229   {
1230     unsigned int result = AO_int_load(addr);
1231     /* Acquire barrier would be useless, since the load could be delayed    */
1232     /* beyond it.                                                           */
1233     AO_nop_read();
1234     return result;
1235   }
1236 # define AO_HAVE_int_load_read
1237 #endif
1238
1239 #if defined(AO_HAVE_int_load_acquire) && defined(AO_HAVE_nop_full) \
1240     && !defined(AO_HAVE_int_load_full)
1241 # define AO_int_load_full(addr) (AO_nop_full(), AO_int_load_acquire(addr))
1242 # define AO_HAVE_int_load_full
1243 #endif
1244
1245 #if !defined(AO_HAVE_int_load_acquire_read) \
1246     && defined(AO_HAVE_int_load_read)
1247 # define AO_int_load_acquire_read(addr) AO_int_load_read(addr)
1248 # define AO_HAVE_int_load_acquire_read
1249 #endif
1250
1251 #if defined(AO_HAVE_int_load_acquire_read) && !defined(AO_HAVE_int_load)
1252 # define AO_int_load(addr) AO_int_load_acquire_read(addr)
1253 # define AO_HAVE_int_load
1254 #endif
1255
1256 #ifdef AO_NO_DD_ORDERING
1257 # if defined(AO_HAVE_int_load_acquire_read)
1258 #   define AO_int_load_dd_acquire_read(addr) AO_int_load_acquire_read(addr)
1259 #   define AO_HAVE_int_load_dd_acquire_read
1260 # endif
1261 #else
1262 # if defined(AO_HAVE_int_load)
1263 #   define AO_int_load_dd_acquire_read(addr) AO_int_load(addr)
1264 #   define AO_HAVE_int_load_dd_acquire_read
1265 # endif
1266 #endif /* !AO_NO_DD_ORDERING */
1267
1268 /* int_store */
1269 #if defined(AO_HAVE_int_store_release) && !defined(AO_HAVE_int_store)
1270 # define AO_int_store(addr, val) AO_int_store_release(addr,val)
1271 # define AO_HAVE_int_store
1272 #endif
1273
1274 #if defined(AO_HAVE_int_store_full) && !defined(AO_HAVE_int_store_release)
1275 # define AO_int_store_release(addr,val) AO_int_store_full(addr,val)
1276 # define AO_HAVE_int_store_release
1277 #endif
1278
1279 #if defined(AO_HAVE_int_store_full) && !defined(AO_HAVE_int_store_write)
1280 # define AO_int_store_write(addr,val) AO_int_store_full(addr,val)
1281 # define AO_HAVE_int_store_write
1282 #endif
1283
1284 #if defined(AO_HAVE_int_store_release) \
1285     && !defined(AO_HAVE_int_store_release_write)
1286 # define AO_int_store_release_write(addr, val) \
1287                             AO_int_store_release(addr,val)
1288 # define AO_HAVE_int_store_release_write
1289 #endif
1290
1291 #if defined(AO_HAVE_int_store_write) && !defined(AO_HAVE_int_store)
1292 # define AO_int_store(addr, val) AO_int_store_write(addr,val)
1293 # define AO_HAVE_int_store
1294 #endif
1295
1296 #if defined(AO_HAVE_int_store) && defined(AO_HAVE_nop_full) \
1297     && !defined(AO_HAVE_int_store_release)
1298 # define AO_int_store_release(addr,val) \
1299                                 (AO_nop_full(), AO_int_store(addr,val))
1300 # define AO_HAVE_int_store_release
1301 #endif
1302
1303 #if defined(AO_HAVE_nop_write) && defined(AO_HAVE_int_store) \
1304     && !defined(AO_HAVE_int_store_write)
1305 # define AO_int_store_write(addr, val) \
1306                                 (AO_nop_write(), AO_int_store(addr,val))
1307 # define AO_HAVE_int_store_write
1308 #endif
1309
1310 #if defined(AO_HAVE_int_store_write) \
1311     && !defined(AO_HAVE_int_store_release_write)
1312 # define AO_int_store_release_write(addr, val) AO_int_store_write(addr,val)
1313 # define AO_HAVE_int_store_release_write
1314 #endif
1315
1316 #if defined(AO_HAVE_int_store_release) && defined(AO_HAVE_nop_full) \
1317     && !defined(AO_HAVE_int_store_full)
1318 # define AO_int_store_full(addr, val) \
1319                         (AO_int_store_release(addr, val), AO_nop_full())
1320 # define AO_HAVE_int_store_full
1321 #endif
1322
1323 /* int_fetch_and_add */
1324 #if defined(AO_HAVE_int_compare_and_swap_full) \
1325     && !defined(AO_HAVE_int_fetch_and_add_full)
1326   AO_INLINE unsigned int
1327   AO_int_fetch_and_add_full(volatile unsigned int *addr,
1328                               unsigned int incr)
1329   {
1330     unsigned int old;
1331     do
1332       {
1333         old = *addr;
1334       }
1335     while (!AO_int_compare_and_swap_full(addr, old, old+incr));
1336     return old;
1337   }
1338 # define AO_HAVE_int_fetch_and_add_full
1339 #endif
1340
1341 #if defined(AO_HAVE_int_compare_and_swap_acquire) \
1342     && !defined(AO_HAVE_int_fetch_and_add_acquire)
1343   AO_INLINE unsigned int
1344   AO_int_fetch_and_add_acquire(volatile unsigned int *addr,
1345                                  unsigned int incr)
1346   {
1347     unsigned int old;
1348     do
1349       {
1350         old = *addr;
1351       }
1352     while (!AO_int_compare_and_swap_acquire(addr, old, old+incr));
1353     return old;
1354   }
1355 # define AO_HAVE_int_fetch_and_add_acquire
1356 #endif
1357
1358 #if defined(AO_HAVE_int_compare_and_swap_release) \
1359     && !defined(AO_HAVE_int_fetch_and_add_release)
1360   AO_INLINE unsigned int
1361   AO_int_fetch_and_add_release(volatile unsigned int *addr,
1362                                  unsigned int incr)
1363   {
1364     unsigned int old;
1365     do
1366       {
1367         old = *addr;
1368       }
1369     while (!AO_int_compare_and_swap_release(addr, old, old+incr));
1370     return old;
1371   }
1372 # define AO_HAVE_int_fetch_and_add_release
1373 #endif
1374
1375 #if defined(AO_HAVE_int_fetch_and_add_full)
1376 # if !defined(AO_HAVE_int_fetch_and_add_release)
1377 #   define AO_int_fetch_and_add_release(addr, val) \
1378                                 AO_int_fetch_and_add_full(addr, val)
1379 #   define AO_HAVE_int_fetch_and_add_release
1380 # endif
1381 # if !defined(AO_HAVE_int_fetch_and_add_acquire)
1382 #   define AO_int_fetch_and_add_acquire(addr, val) \
1383                                 AO_int_fetch_and_add_full(addr, val)
1384 #   define AO_HAVE_int_fetch_and_add_acquire
1385 # endif
1386 # if !defined(AO_HAVE_int_fetch_and_add_write)
1387 #   define AO_int_fetch_and_add_write(addr, val) \
1388                                 AO_int_fetch_and_add_full(addr, val)
1389 #   define AO_HAVE_int_fetch_and_add_write
1390 # endif
1391 # if !defined(AO_HAVE_int_fetch_and_add_read)
1392 #   define AO_int_fetch_and_add_read(addr, val) \
1393                                 AO_int_fetch_and_add_full(addr, val)
1394 #   define AO_HAVE_int_fetch_and_add_read
1395 # endif
1396 #endif /* AO_HAVE_int_fetch_and_add_full */
1397
1398 #if !defined(AO_HAVE_int_fetch_and_add) \
1399     && defined(AO_HAVE_int_fetch_and_add_release)
1400 # define AO_int_fetch_and_add(addr, val) \
1401                                 AO_int_fetch_and_add_release(addr, val)
1402 # define AO_HAVE_int_fetch_and_add
1403 #endif
1404 #if !defined(AO_HAVE_int_fetch_and_add) \
1405     && defined(AO_HAVE_int_fetch_and_add_acquire)
1406 # define AO_int_fetch_and_add(addr, val) \
1407                                 AO_int_fetch_and_add_acquire(addr, val)
1408 # define AO_HAVE_int_fetch_and_add
1409 #endif
1410 #if !defined(AO_HAVE_int_fetch_and_add) \
1411     && defined(AO_HAVE_int_fetch_and_add_write)
1412 # define AO_int_fetch_and_add(addr, val) \
1413                                 AO_int_fetch_and_add_write(addr, val)
1414 # define AO_HAVE_int_fetch_and_add
1415 #endif
1416 #if !defined(AO_HAVE_int_fetch_and_add) \
1417     && defined(AO_HAVE_int_fetch_and_add_read)
1418 # define AO_int_fetch_and_add(addr, val) \
1419                                 AO_int_fetch_and_add_read(addr, val)
1420 # define AO_HAVE_int_fetch_and_add
1421 #endif
1422
1423 #if defined(AO_HAVE_int_fetch_and_add_acquire) \
1424     && defined(AO_HAVE_nop_full) && !defined(AO_HAVE_int_fetch_and_add_full)
1425 # define AO_int_fetch_and_add_full(addr, val) \
1426                 (AO_nop_full(), AO_int_fetch_and_add_acquire(addr, val))
1427 # define AO_HAVE_int_fetch_and_add_full
1428 #endif
1429
1430 #if !defined(AO_HAVE_int_fetch_and_add_release_write) \
1431     && defined(AO_HAVE_int_fetch_and_add_write)
1432 # define AO_int_fetch_and_add_release_write(addr, val) \
1433                                 AO_int_fetch_and_add_write(addr, val)
1434 # define AO_HAVE_int_fetch_and_add_release_write
1435 #endif
1436 #if !defined(AO_HAVE_int_fetch_and_add_release_write) \
1437     && defined(AO_HAVE_int_fetch_and_add_release)
1438 # define AO_int_fetch_and_add_release_write(addr, val) \
1439                                 AO_int_fetch_and_add_release(addr, val)
1440 # define AO_HAVE_int_fetch_and_add_release_write
1441 #endif
1442
1443 #if !defined(AO_HAVE_int_fetch_and_add_acquire_read) \
1444     && defined(AO_HAVE_int_fetch_and_add_read)
1445 # define AO_int_fetch_and_add_acquire_read(addr, val) \
1446                                 AO_int_fetch_and_add_read(addr, val)
1447 # define AO_HAVE_int_fetch_and_add_acquire_read
1448 #endif
1449 #if !defined(AO_HAVE_int_fetch_and_add_acquire_read) \
1450     && defined(AO_HAVE_int_fetch_and_add_acquire)
1451 # define AO_int_fetch_and_add_acquire_read(addr, val) \
1452                                 AO_int_fetch_and_add_acquire(addr, val)
1453 # define AO_HAVE_int_fetch_and_add_acquire_read
1454 #endif
1455
1456 #ifdef AO_NO_DD_ORDERING
1457 # if defined(AO_HAVE_int_fetch_and_add_acquire_read)
1458 #   define AO_int_fetch_and_add_dd_acquire_read(addr, val) \
1459                                 AO_int_fetch_and_add_acquire_read(addr, val)
1460 #   define AO_HAVE_int_fetch_and_add_dd_acquire_read
1461 # endif
1462 #else
1463 # if defined(AO_HAVE_int_fetch_and_add)
1464 #   define AO_int_fetch_and_add_dd_acquire_read(addr, val) \
1465                                 AO_int_fetch_and_add(addr, val)
1466 #   define AO_HAVE_int_fetch_and_add_dd_acquire_read
1467 # endif
1468 #endif /* !AO_NO_DD_ORDERING */
1469
1470 /* int_fetch_and_add1 */
1471 #if defined(AO_HAVE_int_fetch_and_add_full) \
1472     && !defined(AO_HAVE_int_fetch_and_add1_full)
1473 # define AO_int_fetch_and_add1_full(addr) \
1474                                 AO_int_fetch_and_add_full(addr,1)
1475 # define AO_HAVE_int_fetch_and_add1_full
1476 #endif
1477 #if defined(AO_HAVE_int_fetch_and_add_release) \
1478     && !defined(AO_HAVE_int_fetch_and_add1_release)
1479 # define AO_int_fetch_and_add1_release(addr) \
1480                                 AO_int_fetch_and_add_release(addr,1)
1481 # define AO_HAVE_int_fetch_and_add1_release
1482 #endif
1483 #if defined(AO_HAVE_int_fetch_and_add_acquire) \
1484     && !defined(AO_HAVE_int_fetch_and_add1_acquire)
1485 # define AO_int_fetch_and_add1_acquire(addr) \
1486                                 AO_int_fetch_and_add_acquire(addr,1)
1487 # define AO_HAVE_int_fetch_and_add1_acquire
1488 #endif
1489 #if defined(AO_HAVE_int_fetch_and_add_write) \
1490     && !defined(AO_HAVE_int_fetch_and_add1_write)
1491 # define AO_int_fetch_and_add1_write(addr) \
1492                                 AO_int_fetch_and_add_write(addr,1)
1493 # define AO_HAVE_int_fetch_and_add1_write
1494 #endif
1495 #if defined(AO_HAVE_int_fetch_and_add_read) \
1496     && !defined(AO_HAVE_int_fetch_and_add1_read)
1497 # define AO_int_fetch_and_add1_read(addr) \
1498                                 AO_int_fetch_and_add_read(addr,1)
1499 # define AO_HAVE_int_fetch_and_add1_read
1500 #endif
1501 #if defined(AO_HAVE_int_fetch_and_add_release_write) \
1502     && !defined(AO_HAVE_int_fetch_and_add1_release_write)
1503 # define AO_int_fetch_and_add1_release_write(addr) \
1504                                 AO_int_fetch_and_add_release_write(addr,1)
1505 # define AO_HAVE_int_fetch_and_add1_release_write
1506 #endif
1507 #if defined(AO_HAVE_int_fetch_and_add_acquire_read) \
1508     && !defined(AO_HAVE_int_fetch_and_add1_acquire_read)
1509 # define AO_int_fetch_and_add1_acquire_read(addr) \
1510                                 AO_int_fetch_and_add_acquire_read(addr,1)
1511 # define AO_HAVE_int_fetch_and_add1_acquire_read
1512 #endif
1513 #if defined(AO_HAVE_int_fetch_and_add) \
1514     && !defined(AO_HAVE_int_fetch_and_add1)
1515 # define AO_int_fetch_and_add1(addr) AO_int_fetch_and_add(addr,1)
1516 # define AO_HAVE_int_fetch_and_add1
1517 #endif
1518
1519 #if defined(AO_HAVE_int_fetch_and_add1_full)
1520 # if !defined(AO_HAVE_int_fetch_and_add1_release)
1521 #   define AO_int_fetch_and_add1_release(addr) \
1522                                 AO_int_fetch_and_add1_full(addr)
1523 #   define AO_HAVE_int_fetch_and_add1_release
1524 # endif
1525 # if !defined(AO_HAVE_int_fetch_and_add1_acquire)
1526 #   define AO_int_fetch_and_add1_acquire(addr) \
1527                                 AO_int_fetch_and_add1_full(addr)
1528 #   define AO_HAVE_int_fetch_and_add1_acquire
1529 # endif
1530 # if !defined(AO_HAVE_int_fetch_and_add1_write)
1531 #   define AO_int_fetch_and_add1_write(addr) \
1532                                 AO_int_fetch_and_add1_full(addr)
1533 #   define AO_HAVE_int_fetch_and_add1_write
1534 # endif
1535 # if !defined(AO_HAVE_int_fetch_and_add1_read)
1536 #   define AO_int_fetch_and_add1_read(addr) \
1537                                 AO_int_fetch_and_add1_full(addr)
1538 #   define AO_HAVE_int_fetch_and_add1_read
1539 # endif
1540 #endif /* AO_HAVE_int_fetch_and_add1_full */
1541
1542 #if !defined(AO_HAVE_int_fetch_and_add1) \
1543     && defined(AO_HAVE_int_fetch_and_add1_release)
1544 # define AO_int_fetch_and_add1(addr) AO_int_fetch_and_add1_release(addr)
1545 # define AO_HAVE_int_fetch_and_add1
1546 #endif
1547 #if !defined(AO_HAVE_int_fetch_and_add1) \
1548     && defined(AO_HAVE_int_fetch_and_add1_acquire)
1549 # define AO_int_fetch_and_add1(addr) AO_int_fetch_and_add1_acquire(addr)
1550 # define AO_HAVE_int_fetch_and_add1
1551 #endif
1552 #if !defined(AO_HAVE_int_fetch_and_add1) \
1553     && defined(AO_HAVE_int_fetch_and_add1_write)
1554 # define AO_int_fetch_and_add1(addr) AO_int_fetch_and_add1_write(addr)
1555 # define AO_HAVE_int_fetch_and_add1
1556 #endif
1557 #if !defined(AO_HAVE_int_fetch_and_add1) \
1558     && defined(AO_HAVE_int_fetch_and_add1_read)
1559 # define AO_int_fetch_and_add1(addr) AO_int_fetch_and_add1_read(addr)
1560 # define AO_HAVE_int_fetch_and_add1
1561 #endif
1562
1563 #if defined(AO_HAVE_int_fetch_and_add1_acquire) \
1564     && defined(AO_HAVE_nop_full) \
1565     && !defined(AO_HAVE_int_fetch_and_add1_full)
1566 # define AO_int_fetch_and_add1_full(addr) \
1567                         (AO_nop_full(), AO_int_fetch_and_add1_acquire(addr))
1568 # define AO_HAVE_int_fetch_and_add1_full
1569 #endif
1570
1571 #if !defined(AO_HAVE_int_fetch_and_add1_release_write) \
1572     && defined(AO_HAVE_int_fetch_and_add1_write)
1573 # define AO_int_fetch_and_add1_release_write(addr) \
1574                                 AO_int_fetch_and_add1_write(addr)
1575 # define AO_HAVE_int_fetch_and_add1_release_write
1576 #endif
1577 #if !defined(AO_HAVE_int_fetch_and_add1_release_write) \
1578     && defined(AO_HAVE_int_fetch_and_add1_release)
1579 # define AO_int_fetch_and_add1_release_write(addr) \
1580                                 AO_int_fetch_and_add1_release(addr)
1581 # define AO_HAVE_int_fetch_and_add1_release_write
1582 #endif
1583 #if !defined(AO_HAVE_int_fetch_and_add1_acquire_read) \
1584     && defined(AO_HAVE_int_fetch_and_add1_read)
1585 # define AO_int_fetch_and_add1_acquire_read(addr) \
1586                                 AO_int_fetch_and_add1_read(addr)
1587 # define AO_HAVE_int_fetch_and_add1_acquire_read
1588 #endif
1589 #if !defined(AO_HAVE_int_fetch_and_add1_acquire_read) \
1590     && defined(AO_HAVE_int_fetch_and_add1_acquire)
1591 # define AO_int_fetch_and_add1_acquire_read(addr) \
1592                                 AO_int_fetch_and_add1_acquire(addr)
1593 # define AO_HAVE_int_fetch_and_add1_acquire_read
1594 #endif
1595
1596 #ifdef AO_NO_DD_ORDERING
1597 # if defined(AO_HAVE_int_fetch_and_add1_acquire_read)
1598 #   define AO_int_fetch_and_add1_dd_acquire_read(addr) \
1599                                 AO_int_fetch_and_add1_acquire_read(addr)
1600 #   define AO_HAVE_int_fetch_and_add1_dd_acquire_read
1601 # endif
1602 #else
1603 # if defined(AO_HAVE_int_fetch_and_add1)
1604 #   define AO_int_fetch_and_add1_dd_acquire_read(addr) \
1605                                 AO_int_fetch_and_add1(addr)
1606 #   define AO_HAVE_int_fetch_and_add1_dd_acquire_read
1607 # endif
1608 #endif /* !AO_NO_DD_ORDERING */
1609
1610 /* int_fetch_and_sub1 */
1611 #if defined(AO_HAVE_int_fetch_and_add_full) \
1612     && !defined(AO_HAVE_int_fetch_and_sub1_full)
1613 # define AO_int_fetch_and_sub1_full(addr) \
1614                 AO_int_fetch_and_add_full(addr,(unsigned int)(-1))
1615 # define AO_HAVE_int_fetch_and_sub1_full
1616 #endif
1617 #if defined(AO_HAVE_int_fetch_and_add_release) \
1618     && !defined(AO_HAVE_int_fetch_and_sub1_release)
1619 # define AO_int_fetch_and_sub1_release(addr) \
1620                 AO_int_fetch_and_add_release(addr,(unsigned int)(-1))
1621 # define AO_HAVE_int_fetch_and_sub1_release
1622 #endif
1623 #if defined(AO_HAVE_int_fetch_and_add_acquire) \
1624     && !defined(AO_HAVE_int_fetch_and_sub1_acquire)
1625 # define AO_int_fetch_and_sub1_acquire(addr) \
1626                 AO_int_fetch_and_add_acquire(addr,(unsigned int)(-1))
1627 # define AO_HAVE_int_fetch_and_sub1_acquire
1628 #endif
1629 #if defined(AO_HAVE_int_fetch_and_add_write) \
1630     && !defined(AO_HAVE_int_fetch_and_sub1_write)
1631 # define AO_int_fetch_and_sub1_write(addr) \
1632                 AO_int_fetch_and_add_write(addr,(unsigned int)(-1))
1633 # define AO_HAVE_int_fetch_and_sub1_write
1634 #endif
1635 #if defined(AO_HAVE_int_fetch_and_add_read) \
1636     && !defined(AO_HAVE_int_fetch_and_sub1_read)
1637 # define AO_int_fetch_and_sub1_read(addr) \
1638                 AO_int_fetch_and_add_read(addr,(unsigned int)(-1))
1639 # define AO_HAVE_int_fetch_and_sub1_read
1640 #endif
1641 #if defined(AO_HAVE_int_fetch_and_add_release_write) \
1642     && !defined(AO_HAVE_int_fetch_and_sub1_release_write)
1643 # define AO_int_fetch_and_sub1_release_write(addr) \
1644         AO_int_fetch_and_add_release_write(addr,(unsigned int)(-1))
1645 # define AO_HAVE_int_fetch_and_sub1_release_write
1646 #endif
1647 #if defined(AO_HAVE_int_fetch_and_add_acquire_read) \
1648     && !defined(AO_HAVE_int_fetch_and_sub1_acquire_read)
1649 # define AO_int_fetch_and_sub1_acquire_read(addr) \
1650         AO_int_fetch_and_add_acquire_read(addr,(unsigned int)(-1))
1651 # define AO_HAVE_int_fetch_and_sub1_acquire_read
1652 #endif
1653 #if defined(AO_HAVE_int_fetch_and_add) \
1654     && !defined(AO_HAVE_int_fetch_and_sub1)
1655 # define AO_int_fetch_and_sub1(addr) \
1656                 AO_int_fetch_and_add(addr,(unsigned int)(-1))
1657 # define AO_HAVE_int_fetch_and_sub1
1658 #endif
1659
1660 #if defined(AO_HAVE_int_fetch_and_sub1_full)
1661 # if !defined(AO_HAVE_int_fetch_and_sub1_release)
1662 #   define AO_int_fetch_and_sub1_release(addr) \
1663                                 AO_int_fetch_and_sub1_full(addr)
1664 #   define AO_HAVE_int_fetch_and_sub1_release
1665 # endif
1666 # if !defined(AO_HAVE_int_fetch_and_sub1_acquire)
1667 #   define AO_int_fetch_and_sub1_acquire(addr) \
1668                                 AO_int_fetch_and_sub1_full(addr)
1669 #   define AO_HAVE_int_fetch_and_sub1_acquire
1670 # endif
1671 # if !defined(AO_HAVE_int_fetch_and_sub1_write)
1672 #   define AO_int_fetch_and_sub1_write(addr) \
1673                                 AO_int_fetch_and_sub1_full(addr)
1674 #   define AO_HAVE_int_fetch_and_sub1_write
1675 # endif
1676 # if !defined(AO_HAVE_int_fetch_and_sub1_read)
1677 #   define AO_int_fetch_and_sub1_read(addr) \
1678                                 AO_int_fetch_and_sub1_full(addr)
1679 #   define AO_HAVE_int_fetch_and_sub1_read
1680 # endif
1681 #endif /* AO_HAVE_int_fetch_and_sub1_full */
1682
1683 #if !defined(AO_HAVE_int_fetch_and_sub1) \
1684     && defined(AO_HAVE_int_fetch_and_sub1_release)
1685 # define AO_int_fetch_and_sub1(addr) AO_int_fetch_and_sub1_release(addr)
1686 # define AO_HAVE_int_fetch_and_sub1
1687 #endif
1688 #if !defined(AO_HAVE_int_fetch_and_sub1) \
1689     && defined(AO_HAVE_int_fetch_and_sub1_acquire)
1690 # define AO_int_fetch_and_sub1(addr) AO_int_fetch_and_sub1_acquire(addr)
1691 # define AO_HAVE_int_fetch_and_sub1
1692 #endif
1693 #if !defined(AO_HAVE_int_fetch_and_sub1) \
1694     && defined(AO_HAVE_int_fetch_and_sub1_write)
1695 # define AO_int_fetch_and_sub1(addr) AO_int_fetch_and_sub1_write(addr)
1696 # define AO_HAVE_int_fetch_and_sub1
1697 #endif
1698 #if !defined(AO_HAVE_int_fetch_and_sub1) \
1699     && defined(AO_HAVE_int_fetch_and_sub1_read)
1700 # define AO_int_fetch_and_sub1(addr) AO_int_fetch_and_sub1_read(addr)
1701 # define AO_HAVE_int_fetch_and_sub1
1702 #endif
1703
1704 #if defined(AO_HAVE_int_fetch_and_sub1_acquire) \
1705     && defined(AO_HAVE_nop_full) \
1706     && !defined(AO_HAVE_int_fetch_and_sub1_full)
1707 # define AO_int_fetch_and_sub1_full(addr) \
1708                         (AO_nop_full(), AO_int_fetch_and_sub1_acquire(addr))
1709 # define AO_HAVE_int_fetch_and_sub1_full
1710 #endif
1711
1712 #if !defined(AO_HAVE_int_fetch_and_sub1_release_write) \
1713     && defined(AO_HAVE_int_fetch_and_sub1_write)
1714 # define AO_int_fetch_and_sub1_release_write(addr) \
1715                                 AO_int_fetch_and_sub1_write(addr)
1716 # define AO_HAVE_int_fetch_and_sub1_release_write
1717 #endif
1718 #if !defined(AO_HAVE_int_fetch_and_sub1_release_write) \
1719     && defined(AO_HAVE_int_fetch_and_sub1_release)
1720 # define AO_int_fetch_and_sub1_release_write(addr) \
1721                                 AO_int_fetch_and_sub1_release(addr)
1722 # define AO_HAVE_int_fetch_and_sub1_release_write
1723 #endif
1724 #if !defined(AO_HAVE_int_fetch_and_sub1_acquire_read) \
1725     && defined(AO_HAVE_int_fetch_and_sub1_read)
1726 # define AO_int_fetch_and_sub1_acquire_read(addr) \
1727                                 AO_int_fetch_and_sub1_read(addr)
1728 # define AO_HAVE_int_fetch_and_sub1_acquire_read
1729 #endif
1730 #if !defined(AO_HAVE_int_fetch_and_sub1_acquire_read) \
1731     && defined(AO_HAVE_int_fetch_and_sub1_acquire)
1732 # define AO_int_fetch_and_sub1_acquire_read(addr) \
1733                                 AO_int_fetch_and_sub1_acquire(addr)
1734 # define AO_HAVE_int_fetch_and_sub1_acquire_read
1735 #endif
1736
1737 #ifdef AO_NO_DD_ORDERING
1738 # if defined(AO_HAVE_int_fetch_and_sub1_acquire_read)
1739 #   define AO_int_fetch_and_sub1_dd_acquire_read(addr) \
1740                                 AO_int_fetch_and_sub1_acquire_read(addr)
1741 #   define AO_HAVE_int_fetch_and_sub1_dd_acquire_read
1742 # endif
1743 #else
1744 # if defined(AO_HAVE_int_fetch_and_sub1)
1745 #   define AO_int_fetch_and_sub1_dd_acquire_read(addr) \
1746                                 AO_int_fetch_and_sub1(addr)
1747 #   define AO_HAVE_int_fetch_and_sub1_dd_acquire_read
1748 # endif
1749 #endif /* !AO_NO_DD_ORDERING */