ARGOBOTS  1059a7c2eb7e3f99f736a9c3a4f6ea476ac1b804
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
abtd_atomic.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #ifndef ABTD_ATOMIC_H_INCLUDED
7 #define ABTD_ATOMIC_H_INCLUDED
8 
9 #include <stdint.h>
10 
11 typedef struct ABTD_atomic_bool {
12  uint8_t val;
14 
15 typedef struct ABTD_atomic_int {
16  int val;
18 
19 typedef struct ABTD_atomic_int32 {
20  int32_t val;
22 
23 typedef struct ABTD_atomic_uint32 {
24  uint32_t val;
26 
27 typedef struct ABTD_atomic_int64 {
28  int64_t val;
30 
31 typedef struct ABTD_atomic_uint64 {
32  uint64_t val;
34 
35 typedef struct ABTD_atomic_ptr {
36  void *val;
38 
39 #define ABTD_ATOMIC_BOOL_STATIC_INITIALIZER(val) \
40  { \
41  (val) \
42  }
43 #define ABTD_ATOMIC_INT_STATIC_INITIALIZER(val) \
44  { \
45  (val) \
46  }
47 #define ABTD_ATOMIC_INT32_STATIC_INITIALIZER(val) \
48  { \
49  (val) \
50  }
51 #define ABTD_ATOMIC_UINT32_STATIC_INITIALIZER(val) \
52  { \
53  (val) \
54  }
55 #define ABTD_ATOMIC_INT64_STATIC_INITIALIZER(val) \
56  { \
57  (val) \
58  }
59 #define ABTD_ATOMIC_UINT64_STATIC_INITIALIZER(val) \
60  { \
61  (val) \
62  }
63 #define ABTD_ATOMIC_PTR_STATIC_INITIALIZER(val) \
64  { \
65  (val) \
66  }
67 
68 static inline int ABTDI_atomic_val_cas_int(ABTD_atomic_int *ptr, int oldv,
69  int newv, int weak)
70 {
71 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
72  int tmp_oldv = oldv;
73  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
74  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
75  return ret ? tmp_oldv : oldv;
76 #else
77  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
78 #endif
79 }
80 
81 static inline int32_t ABTDI_atomic_val_cas_int32(ABTD_atomic_int32 *ptr,
82  int32_t oldv, int32_t newv,
83  int weak)
84 {
85 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
86  int32_t tmp_oldv = oldv;
87  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
88  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
89  return ret ? tmp_oldv : oldv;
90 #else
91  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
92 #endif
93 }
94 
95 static inline uint32_t ABTDI_atomic_val_cas_uint32(ABTD_atomic_uint32 *ptr,
96  uint32_t oldv, uint32_t newv,
97  int weak)
98 {
99 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
100  uint32_t tmp_oldv = oldv;
101  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
102  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
103  return ret ? tmp_oldv : oldv;
104 #else
105  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
106 #endif
107 }
108 
110  int64_t oldv, int64_t newv,
111  int weak)
112 {
113 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
114  int64_t tmp_oldv = oldv;
115  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
116  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
117  return ret ? tmp_oldv : oldv;
118 #else
119  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
120 #endif
121 }
122 
124  uint64_t oldv, uint64_t newv,
125  int weak)
126 {
127 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
128  uint64_t tmp_oldv = oldv;
129  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
130  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
131  return ret ? tmp_oldv : oldv;
132 #else
133  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
134 #endif
135 }
136 
137 static inline void *ABTDI_atomic_val_cas_ptr(ABTD_atomic_ptr *ptr, void *oldv,
138  void *newv, int weak)
139 {
140 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
141  void *tmp_oldv = oldv;
142  int ret = __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
143  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
144  return ret ? tmp_oldv : oldv;
145 #else
146  return __sync_val_compare_and_swap(&ptr->val, oldv, newv);
147 #endif
148 }
149 
150 static inline int ABTDI_atomic_bool_cas_int(ABTD_atomic_int *ptr, int oldv,
151  int newv, int weak)
152 {
153 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
154  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
155  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
156 #else
157  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
158 #endif
159 }
160 
162  int32_t oldv, int32_t newv,
163  int weak)
164 {
165 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
166  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
167  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
168 #else
169  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
170 #endif
171 }
172 
174  uint32_t oldv, uint32_t newv,
175  int weak)
176 {
177 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
178  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
179  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
180 #else
181  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
182 #endif
183 }
184 
186  int64_t oldv, int64_t newv,
187  int weak)
188 {
189 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
190  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
191  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
192 #else
193  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
194 #endif
195 }
196 
198  uint64_t oldv, uint64_t newv,
199  int weak)
200 {
201 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
202  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
203  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
204 #else
205  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
206 #endif
207 }
208 
209 static inline int ABTDI_atomic_bool_cas_ptr(ABTD_atomic_ptr *ptr, void *oldv,
210  void *newv, int weak)
211 {
212 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
213  return __atomic_compare_exchange_n(&ptr->val, &oldv, newv, weak,
214  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
215 #else
216  return __sync_bool_compare_and_swap(&ptr->val, oldv, newv);
217 #endif
218 }
219 
220 static inline int ABTD_atomic_val_cas_weak_int(ABTD_atomic_int *ptr, int oldv,
221  int newv)
222 {
223  return ABTDI_atomic_val_cas_int(ptr, oldv, newv, 1);
224 }
225 
227  int32_t oldv, int32_t newv)
228 {
229  return ABTDI_atomic_val_cas_int32(ptr, oldv, newv, 1);
230 }
231 
233  uint32_t oldv,
234  uint32_t newv)
235 {
236  return ABTDI_atomic_val_cas_uint32(ptr, oldv, newv, 1);
237 }
238 
240  int64_t oldv, int64_t newv)
241 {
242  return ABTDI_atomic_val_cas_int64(ptr, oldv, newv, 1);
243 }
244 
246  uint64_t oldv,
247  uint64_t newv)
248 {
249  return ABTDI_atomic_val_cas_uint64(ptr, oldv, newv, 1);
250 }
251 
253  void *oldv, void *newv)
254 {
255  return ABTDI_atomic_val_cas_ptr(ptr, oldv, newv, 1);
256 }
257 
258 static inline int ABTD_atomic_val_cas_strong_int(ABTD_atomic_int *ptr, int oldv,
259  int newv)
260 {
261  return ABTDI_atomic_val_cas_int(ptr, oldv, newv, 0);
262 }
263 
265  int32_t oldv,
266  int32_t newv)
267 {
268  return ABTDI_atomic_val_cas_int32(ptr, oldv, newv, 0);
269 }
270 
271 static inline uint32_t
273  uint32_t newv)
274 {
275  return ABTDI_atomic_val_cas_uint32(ptr, oldv, newv, 0);
276 }
277 
279  int64_t oldv,
280  int64_t newv)
281 {
282  return ABTDI_atomic_val_cas_int64(ptr, oldv, newv, 0);
283 }
284 
285 static inline uint64_t
287  uint64_t newv)
288 {
289  return ABTDI_atomic_val_cas_uint64(ptr, oldv, newv, 0);
290 }
291 
293  void *oldv, void *newv)
294 {
295  return ABTDI_atomic_val_cas_ptr(ptr, oldv, newv, 0);
296 }
297 
298 static inline int ABTD_atomic_bool_cas_weak_int(ABTD_atomic_int *ptr, int oldv,
299  int newv)
300 {
301  return ABTDI_atomic_bool_cas_int(ptr, oldv, newv, 1);
302 }
303 
305  int32_t oldv, int32_t newv)
306 {
307  return ABTDI_atomic_bool_cas_int32(ptr, oldv, newv, 1);
308 }
309 
311  uint32_t oldv, uint32_t newv)
312 {
313  return ABTDI_atomic_bool_cas_uint32(ptr, oldv, newv, 1);
314 }
315 
317  int64_t oldv, int64_t newv)
318 {
319  return ABTDI_atomic_bool_cas_int64(ptr, oldv, newv, 1);
320 }
321 
323  uint64_t oldv, uint64_t newv)
324 {
325  return ABTDI_atomic_bool_cas_uint64(ptr, oldv, newv, 1);
326 }
327 
329  void *oldv, void *newv)
330 {
331  return ABTDI_atomic_bool_cas_ptr(ptr, oldv, newv, 1);
332 }
333 
335  int oldv, int newv)
336 {
337  return ABTDI_atomic_bool_cas_int(ptr, oldv, newv, 0);
338 }
339 
341  int32_t oldv, int32_t newv)
342 {
343  return ABTDI_atomic_bool_cas_int32(ptr, oldv, newv, 0);
344 }
345 
347  uint32_t oldv,
348  uint32_t newv)
349 {
350  return ABTDI_atomic_bool_cas_uint32(ptr, oldv, newv, 0);
351 }
352 
354  int64_t oldv, int64_t newv)
355 {
356  return ABTDI_atomic_bool_cas_int64(ptr, oldv, newv, 0);
357 }
358 
360  uint64_t oldv,
361  uint64_t newv)
362 {
363  return ABTDI_atomic_bool_cas_uint64(ptr, oldv, newv, 0);
364 }
365 
367  void *oldv, void *newv)
368 {
369  return ABTDI_atomic_bool_cas_ptr(ptr, oldv, newv, 0);
370 }
371 
372 static inline int ABTD_atomic_fetch_add_int(ABTD_atomic_int *ptr, int v)
373 {
374 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
375  return __atomic_fetch_add(&ptr->val, v, __ATOMIC_ACQ_REL);
376 #else
377  return __sync_fetch_and_add(&ptr->val, v);
378 #endif
379 }
380 
382  int32_t v)
383 {
384 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
385  return __atomic_fetch_add(&ptr->val, v, __ATOMIC_ACQ_REL);
386 #else
387  return __sync_fetch_and_add(&ptr->val, v);
388 #endif
389 }
390 
392  uint32_t v)
393 {
394 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
395  return __atomic_fetch_add(&ptr->val, v, __ATOMIC_ACQ_REL);
396 #else
397  return __sync_fetch_and_add(&ptr->val, v);
398 #endif
399 }
400 
402  int64_t v)
403 {
404 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
405  return __atomic_fetch_add(&ptr->val, v, __ATOMIC_ACQ_REL);
406 #else
407  return __sync_fetch_and_add(&ptr->val, v);
408 #endif
409 }
410 
412  uint64_t v)
413 {
414 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
415  return __atomic_fetch_add(&ptr->val, v, __ATOMIC_ACQ_REL);
416 #else
417  return __sync_fetch_and_add(&ptr->val, v);
418 #endif
419 }
420 
421 static inline int ABTD_atomic_fetch_sub_int(ABTD_atomic_int *ptr, int v)
422 {
423 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
424  return __atomic_fetch_sub(&ptr->val, v, __ATOMIC_ACQ_REL);
425 #else
426  return __sync_fetch_and_sub(&ptr->val, v);
427 #endif
428 }
429 
431  int32_t v)
432 {
433 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
434  return __atomic_fetch_sub(&ptr->val, v, __ATOMIC_ACQ_REL);
435 #else
436  return __sync_fetch_and_sub(&ptr->val, v);
437 #endif
438 }
439 
441  uint32_t v)
442 {
443 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
444  return __atomic_fetch_sub(&ptr->val, v, __ATOMIC_ACQ_REL);
445 #else
446  return __sync_fetch_and_sub(&ptr->val, v);
447 #endif
448 }
449 
451  int64_t v)
452 {
453 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
454  return __atomic_fetch_sub(&ptr->val, v, __ATOMIC_ACQ_REL);
455 #else
456  return __sync_fetch_and_sub(&ptr->val, v);
457 #endif
458 }
459 
461  uint64_t v)
462 {
463 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
464  return __atomic_fetch_sub(&ptr->val, v, __ATOMIC_ACQ_REL);
465 #else
466  return __sync_fetch_and_sub(&ptr->val, v);
467 #endif
468 }
469 
470 static inline int ABTD_atomic_fetch_and_int(ABTD_atomic_int *ptr, int v)
471 {
472 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
473  return __atomic_fetch_and(&ptr->val, v, __ATOMIC_ACQ_REL);
474 #else
475  return __sync_fetch_and_and(&ptr->val, v);
476 #endif
477 }
478 
480  int32_t v)
481 {
482 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
483  return __atomic_fetch_and(&ptr->val, v, __ATOMIC_ACQ_REL);
484 #else
485  return __sync_fetch_and_and(&ptr->val, v);
486 #endif
487 }
488 
490  uint32_t v)
491 {
492 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
493  return __atomic_fetch_and(&ptr->val, v, __ATOMIC_ACQ_REL);
494 #else
495  return __sync_fetch_and_and(&ptr->val, v);
496 #endif
497 }
498 
500  int64_t v)
501 {
502 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
503  return __atomic_fetch_and(&ptr->val, v, __ATOMIC_ACQ_REL);
504 #else
505  return __sync_fetch_and_and(&ptr->val, v);
506 #endif
507 }
508 
510  uint64_t v)
511 {
512 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
513  return __atomic_fetch_and(&ptr->val, v, __ATOMIC_ACQ_REL);
514 #else
515  return __sync_fetch_and_and(&ptr->val, v);
516 #endif
517 }
518 
519 static inline int ABTD_atomic_fetch_or_int(ABTD_atomic_int *ptr, int v)
520 {
521 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
522  return __atomic_fetch_or(&ptr->val, v, __ATOMIC_ACQ_REL);
523 #else
524  return __sync_fetch_and_or(&ptr->val, v);
525 #endif
526 }
527 
529  int32_t v)
530 {
531 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
532  return __atomic_fetch_or(&ptr->val, v, __ATOMIC_ACQ_REL);
533 #else
534  return __sync_fetch_and_or(&ptr->val, v);
535 #endif
536 }
537 
539  uint32_t v)
540 {
541 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
542  return __atomic_fetch_or(&ptr->val, v, __ATOMIC_ACQ_REL);
543 #else
544  return __sync_fetch_and_or(&ptr->val, v);
545 #endif
546 }
547 
549  int64_t v)
550 {
551 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
552  return __atomic_fetch_or(&ptr->val, v, __ATOMIC_ACQ_REL);
553 #else
554  return __sync_fetch_and_or(&ptr->val, v);
555 #endif
556 }
557 
559  uint64_t v)
560 {
561 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
562  return __atomic_fetch_or(&ptr->val, v, __ATOMIC_ACQ_REL);
563 #else
564  return __sync_fetch_and_or(&ptr->val, v);
565 #endif
566 }
567 
568 static inline int ABTD_atomic_fetch_xor_int(ABTD_atomic_int *ptr, int v)
569 {
570 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
571  return __atomic_fetch_xor(&ptr->val, v, __ATOMIC_ACQ_REL);
572 #else
573  return __sync_fetch_and_xor(&ptr->val, v);
574 #endif
575 }
576 
578  int32_t v)
579 {
580 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
581  return __atomic_fetch_xor(&ptr->val, v, __ATOMIC_ACQ_REL);
582 #else
583  return __sync_fetch_and_xor(&ptr->val, v);
584 #endif
585 }
586 
588  uint32_t v)
589 {
590 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
591  return __atomic_fetch_xor(&ptr->val, v, __ATOMIC_ACQ_REL);
592 #else
593  return __sync_fetch_and_xor(&ptr->val, v);
594 #endif
595 }
596 
598  int64_t v)
599 {
600 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
601  return __atomic_fetch_xor(&ptr->val, v, __ATOMIC_ACQ_REL);
602 #else
603  return __sync_fetch_and_xor(&ptr->val, v);
604 #endif
605 }
606 
608  uint64_t v)
609 {
610 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
611  return __atomic_fetch_xor(&ptr->val, v, __ATOMIC_ACQ_REL);
612 #else
613  return __sync_fetch_and_xor(&ptr->val, v);
614 #endif
615 }
616 
618 {
619  /* return 0 if this test_and_set succeeds to set a value. */
620 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
621  return __atomic_test_and_set(&ptr->val, __ATOMIC_ACQUIRE);
622 #else
623  return __sync_lock_test_and_set(&ptr->val, 1);
624 #endif
625 }
626 
628 {
629 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
630  __atomic_clear(&ptr->val, __ATOMIC_RELAXED);
631 #else
632  *(volatile uint8_t *)&ptr->val = 0;
633 #endif
634 }
635 
637 {
638 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
639  __atomic_clear(&ptr->val, __ATOMIC_RELEASE);
640 #else
641  __sync_lock_release(&ptr->val);
642 #endif
643 }
644 
645 static inline ABT_bool
647 {
648 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
649 #ifndef __SUNPRO_C
650  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED) ? ABT_TRUE : ABT_FALSE;
651 #else
652  /* __atomic_load_n() takes a non-const pointer. */
653  return __atomic_load_n((uint8_t *)&ptr->val, __ATOMIC_RELAXED) ? ABT_TRUE
654  : ABT_FALSE;
655 #endif
656 #else
657  return (*(volatile uint8_t *)&ptr->val) ? ABT_TRUE : ABT_FALSE;
658 #endif
659 }
660 
661 static inline int ABTD_atomic_relaxed_load_int(const ABTD_atomic_int *ptr)
662 {
663 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
664 #ifndef __SUNPRO_C
665  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
666 #else
667  return __atomic_load_n((int *)&ptr->val, __ATOMIC_RELAXED);
668 #endif
669 #else
670  return *(volatile int *)&ptr->val;
671 #endif
672 }
673 
674 static inline int32_t
676 {
677 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
678 #ifndef __SUNPRO_C
679  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
680 #else
681  return __atomic_load_n((int32_t *)&ptr->val, __ATOMIC_RELAXED);
682 #endif
683 #else
684  return *(volatile int32_t *)&ptr->val;
685 #endif
686 }
687 
688 static inline uint32_t
690 {
691 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
692 #ifndef __SUNPRO_C
693  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
694 #else
695  return __atomic_load_n((uint32_t *)&ptr->val, __ATOMIC_RELAXED);
696 #endif
697 #else
698  return *(volatile uint32_t *)&ptr->val;
699 #endif
700 }
701 
702 static inline int64_t
704 {
705 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
706 #ifndef __SUNPRO_C
707  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
708 #else
709  return __atomic_load_n((int64_t *)&ptr->val, __ATOMIC_RELAXED);
710 #endif
711 #else
712  return *(volatile int64_t *)&ptr->val;
713 #endif
714 }
715 
716 static inline uint64_t
718 {
719  /* return 0 if this test_and_set succeeds to set a value. */
720 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
721 #ifndef __SUNPRO_C
722  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
723 #else
724  return __atomic_load_n((uint64_t *)&ptr->val, __ATOMIC_RELAXED);
725 #endif
726 #else
727  return *(volatile uint64_t *)&ptr->val;
728 #endif
729 }
730 
731 static inline void *ABTD_atomic_relaxed_load_ptr(const ABTD_atomic_ptr *ptr)
732 {
733  /* return 0 if this test_and_set succeeds to set a value. */
734 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
735 #ifndef __SUNPRO_C
736  return __atomic_load_n(&ptr->val, __ATOMIC_RELAXED);
737 #else
738  return __atomic_load_n((void **)&ptr->val, __ATOMIC_RELAXED);
739 #endif
740 #else
741  return *(void *volatile *)&ptr->val;
742 #endif
743 }
744 
745 static inline ABT_bool
747 {
748 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
749 #ifndef __SUNPRO_C
750  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE) ? ABT_TRUE : ABT_FALSE;
751 #else
752  return __atomic_load_n((uint8_t *)&ptr->val, __ATOMIC_ACQUIRE) ? ABT_TRUE
753  : ABT_FALSE;
754 #endif
755 #else
756  __sync_synchronize();
757  ABT_bool val = *(volatile uint8_t *)&ptr->val ? ABT_TRUE : ABT_FALSE;
758  __sync_synchronize();
759  return val;
760 #endif
761 }
762 
763 static inline int ABTD_atomic_acquire_load_int(const ABTD_atomic_int *ptr)
764 {
765 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
766 #ifndef __SUNPRO_C
767  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
768 #else
769  return __atomic_load_n((int *)&ptr->val, __ATOMIC_ACQUIRE);
770 #endif
771 #else
772  __sync_synchronize();
773  int val = *(volatile int *)&ptr->val;
774  __sync_synchronize();
775  return val;
776 #endif
777 }
778 
779 static inline int32_t
781 {
782 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
783 #ifndef __SUNPRO_C
784  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
785 #else
786  return __atomic_load_n((int32_t *)&ptr->val, __ATOMIC_ACQUIRE);
787 #endif
788 #else
789  __sync_synchronize();
790  int32_t val = *(volatile int32_t *)&ptr->val;
791  __sync_synchronize();
792  return val;
793 #endif
794 }
795 
796 static inline uint32_t
798 {
799 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
800 #ifndef __SUNPRO_C
801  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
802 #else
803  return __atomic_load_n((uint32_t *)&ptr->val, __ATOMIC_ACQUIRE);
804 #endif
805 #else
806  __sync_synchronize();
807  uint32_t val = *(volatile uint32_t *)&ptr->val;
808  __sync_synchronize();
809  return val;
810 #endif
811 }
812 
813 static inline int64_t
815 {
816 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
817 #ifndef __SUNPRO_C
818  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
819 #else
820  return __atomic_load_n((int64_t *)&ptr->val, __ATOMIC_ACQUIRE);
821 #endif
822 #else
823  __sync_synchronize();
824  int64_t val = *(volatile int64_t *)&ptr->val;
825  __sync_synchronize();
826  return val;
827 #endif
828 }
829 
830 static inline uint64_t
832 {
833  /* return 0 if this test_and_set succeeds to set a value. */
834 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
835 #ifndef __SUNPRO_C
836  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
837 #else
838  return __atomic_load_n((uint64_t *)&ptr->val, __ATOMIC_ACQUIRE);
839 #endif
840 #else
841  __sync_synchronize();
842  uint64_t val = *(volatile uint64_t *)&ptr->val;
843  __sync_synchronize();
844  return val;
845 #endif
846 }
847 
848 static inline void *ABTD_atomic_acquire_load_ptr(const ABTD_atomic_ptr *ptr)
849 {
850  /* return 0 if this test_and_set succeeds to set a value. */
851 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
852 #ifndef __SUNPRO_C
853  return __atomic_load_n(&ptr->val, __ATOMIC_ACQUIRE);
854 #else
855  return __atomic_load_n((void **)&ptr->val, __ATOMIC_ACQUIRE);
856 #endif
857 #else
858  __sync_synchronize();
859  void *val = *(void *volatile *)&ptr->val;
860  __sync_synchronize();
861  return val;
862 #endif
863 }
864 
865 static inline void ABTD_atomic_relaxed_store_int(ABTD_atomic_int *ptr, int val)
866 {
867 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
868  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
869 #else
870  *(volatile int *)&ptr->val = val;
871 #endif
872 }
873 
875  int32_t val)
876 {
877 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
878  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
879 #else
880  *(volatile int32_t *)&ptr->val = val;
881 #endif
882 }
883 
885  uint32_t val)
886 {
887 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
888  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
889 #else
890  *(volatile uint32_t *)&ptr->val = val;
891 #endif
892 }
893 
895  int64_t val)
896 {
897 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
898  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
899 #else
900  *(volatile int64_t *)&ptr->val = val;
901 #endif
902 }
903 
905  uint64_t val)
906 {
907 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
908  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
909 #else
910  *(volatile uint64_t *)&ptr->val = val;
911 #endif
912 }
913 
915  void *val)
916 {
917 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
918  __atomic_store_n(&ptr->val, val, __ATOMIC_RELAXED);
919 #else
920  *(void *volatile *)&ptr->val = val;
921 #endif
922 }
923 
924 static inline void ABTD_atomic_release_store_int(ABTD_atomic_int *ptr, int val)
925 {
926 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
927  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
928 #else
929  __sync_synchronize();
930  *(volatile int *)&ptr->val = val;
931  __sync_synchronize();
932 #endif
933 }
934 
936  int32_t val)
937 {
938 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
939  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
940 #else
941  __sync_synchronize();
942  *(volatile int32_t *)&ptr->val = val;
943  __sync_synchronize();
944 #endif
945 }
946 
948  uint32_t val)
949 {
950 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
951  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
952 #else
953  __sync_synchronize();
954  *(volatile uint32_t *)&ptr->val = val;
955  __sync_synchronize();
956 #endif
957 }
958 
960  int64_t val)
961 {
962 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
963  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
964 #else
965  __sync_synchronize();
966  *(volatile int64_t *)&ptr->val = val;
967  __sync_synchronize();
968 #endif
969 }
970 
972  uint64_t val)
973 {
974 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
975  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
976 #else
977  __sync_synchronize();
978  *(volatile uint64_t *)&ptr->val = val;
979  __sync_synchronize();
980 #endif
981 }
982 
984  void *val)
985 {
986 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
987  __atomic_store_n(&ptr->val, val, __ATOMIC_RELEASE);
988 #else
989  __sync_synchronize();
990  *(void *volatile *)&ptr->val = val;
991  __sync_synchronize();
992 #endif
993 }
994 
995 static inline int ABTD_atomic_exchange_int(ABTD_atomic_int *ptr, int v)
996 {
997 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
998  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
999 #else
1000  int val;
1001  do {
1002  val = ABTD_atomic_acquire_load_int(ptr);
1003  } while (!ABTD_atomic_bool_cas_weak_int(ptr, val, v));
1004  return val;
1005 #endif
1006 }
1007 
1009  int32_t v)
1010 {
1011 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1012  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
1013 #else
1014  int32_t val;
1015  do {
1016  val = ABTD_atomic_acquire_load_int32(ptr);
1017  } while (!ABTD_atomic_bool_cas_weak_int32(ptr, val, v));
1018  return val;
1019 #endif
1020 }
1021 
1023  uint32_t v)
1024 {
1025 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1026  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
1027 #else
1028  uint32_t val;
1029  do {
1031  } while (!ABTD_atomic_bool_cas_weak_uint32(ptr, val, v));
1032  return val;
1033 #endif
1034 }
1035 
1037  int64_t v)
1038 {
1039 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1040  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
1041 #else
1042  int64_t val;
1043  do {
1044  val = ABTD_atomic_acquire_load_int64(ptr);
1045  } while (!ABTD_atomic_bool_cas_weak_int64(ptr, val, v));
1046  return val;
1047 #endif
1048 }
1049 
1051  uint64_t v)
1052 {
1053 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1054  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
1055 #else
1056  uint64_t val;
1057  do {
1059  } while (!ABTD_atomic_bool_cas_weak_uint64(ptr, val, v));
1060  return val;
1061 #endif
1062 }
1063 
1064 static inline void *ABTD_atomic_exchange_ptr(ABTD_atomic_ptr *ptr, void *v)
1065 {
1066 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1067  return __atomic_exchange_n(&ptr->val, v, __ATOMIC_ACQ_REL);
1068 #else
1069  void *val;
1070  do {
1071  val = ABTD_atomic_acquire_load_ptr(ptr);
1072  } while (!ABTD_atomic_bool_cas_weak_ptr(ptr, val, v));
1073  return val;
1074 #endif
1075 }
1076 
1077 static inline void ABTD_atomic_mem_barrier(void)
1078 {
1079 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1080  __atomic_thread_fence(__ATOMIC_ACQ_REL);
1081 #else
1082  __sync_synchronize();
1083 #endif
1084 }
1085 
1086 static inline void ABTD_compiler_barrier(void)
1087 {
1088  __asm__ __volatile__("" ::: "memory");
1089 }
1090 
1091 static inline void ABTD_atomic_pause(void)
1092 {
1093 #ifdef __x86_64__
1094  __asm__ __volatile__("pause" ::: "memory");
1095 #endif
1096 }
1097 
1098 /*
1099  * Declare an atomic tagged pointer here. This atomic type supports very few
1100  * functions, which are basically for the lock-free LIFO implementation.
1101  *
1102  * If ABTD_ATOMIC_SUPPORT_TAGGED_PTR is not defined, this atomic type is
1103  * disabled.
1104  */
1105 #undef ABTD_ATOMIC_SUPPORT_TAGGED_PTR
1106 
1107 #if SIZEOF_VOID_P == 4 || (SIZEOF_VOID_P == 8 && ABT_CONFIG_HAVE_ATOMIC_INT128)
1108 
1109 #define ABTD_ATOMIC_SUPPORT_TAGGED_PTR 1
1110 
1111 typedef struct ABTD_atomic_tagged_ptr {
1112  void *ptr;
1113  size_t tag;
1114 } ABTD_atomic_tagged_ptr;
1115 
1116 #define ABTD_ATOMIC_TAGGED_PTR_STATIC_INITIALIZER(ptr, tag) \
1117  { \
1118  (ptr), (tag) \
1119  }
1120 
1121 #if SIZEOF_VOID_P == 8
1122 #include "asm/abtd_asm_int128_cas.h"
1123 #endif
1124 
1125 static inline int
1126 ABTD_atomic_bool_cas_weak_tagged_ptr(ABTD_atomic_tagged_ptr *tagged_ptr,
1127  void *old_ptr, size_t old_tag,
1128  void *new_ptr, size_t new_tag)
1129 {
1130 #if SIZEOF_VOID_P == 4
1131 
1132  ABTI_STATIC_ASSERT(sizeof(ABTD_atomic_tagged_ptr) == 8);
1133  /* Use uint64_t for this. */
1134  typedef union {
1135  ABTD_atomic_tagged_ptr tagged_ptr;
1136  uint64_t val;
1137  } atomic_tagged_ptr_t;
1138  atomic_tagged_ptr_t oldv = {
1139  ABTD_ATOMIC_TAGGED_PTR_STATIC_INITIALIZER(old_ptr, old_tag)
1140  };
1141  atomic_tagged_ptr_t newv = {
1142  ABTD_ATOMIC_TAGGED_PTR_STATIC_INITIALIZER(new_ptr, new_tag)
1143  };
1144  uint64_t *p_val = (uint64_t *)tagged_ptr;
1145 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1146  return __atomic_compare_exchange_n(p_val, &oldv.val, newv.val, 1,
1147  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE);
1148 #else
1149  return __sync_bool_compare_and_swap(&p_ptr, oldv, newv);
1150 #endif
1151 
1152 #elif SIZEOF_VOID_P == 8
1153 
1154  ABTI_STATIC_ASSERT(sizeof(ABTD_atomic_tagged_ptr) == 16);
1155  typedef union {
1156  ABTD_atomic_tagged_ptr tagged_ptr;
1157  __int128 val;
1158  } atomic_tagged_ptr_t;
1159  __int128 *p_val = (__int128 *)tagged_ptr;
1160  atomic_tagged_ptr_t oldv = {
1161  ABTD_ATOMIC_TAGGED_PTR_STATIC_INITIALIZER(old_ptr, old_tag)
1162  };
1163  atomic_tagged_ptr_t newv = {
1164  ABTD_ATOMIC_TAGGED_PTR_STATIC_INITIALIZER(new_ptr, new_tag)
1165  };
1166 
1167  return ABTD_asm_bool_cas_weak_int128(p_val, oldv.val, newv.val);
1168 
1169 #else /* SIZEOF_VOID_P */
1170 
1171 #error "Unsupported pointer size."
1172 
1173 #endif
1174 }
1175 
1176 /* The following loads and stores follow relaxed/acquire/release semantics, but
1177  * these operations are not "atomic" as a pair of a pointer and a tag (i.e.,
1178  * ptr and tag are accessed in a non-atomic manner). */
1179 static inline void ABTD_atomic_relaxed_load_non_atomic_tagged_ptr(
1180  const ABTD_atomic_tagged_ptr *tagged_ptr, void **p_ptr, size_t *p_tag)
1181 {
1182 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1183 #ifndef __SUNPRO_C
1184  *p_ptr = __atomic_load_n(&tagged_ptr->ptr, __ATOMIC_RELAXED);
1185  *p_tag = __atomic_load_n(&tagged_ptr->tag, __ATOMIC_RELAXED);
1186 #else
1187  *p_ptr = __atomic_load_n((void **)&tagged_ptr->ptr, __ATOMIC_RELAXED);
1188  *p_tag = __atomic_load_n((size_t *)&tagged_ptr->tag, __ATOMIC_RELAXED);
1189 #endif
1190 #else
1191  *p_ptr = *(void *volatile *)&tagged_ptr->ptr;
1192  *p_tag = *(volatile size_t *)&tagged_ptr->tag;
1193 #endif
1194 }
1195 
1196 static inline void ABTD_atomic_relaxed_store_non_atomic_tagged_ptr(
1197  ABTD_atomic_tagged_ptr *tagged_ptr, void *ptr, size_t tag)
1198 {
1199 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1200  __atomic_store_n(&tagged_ptr->ptr, ptr, __ATOMIC_RELAXED);
1201  __atomic_store_n(&tagged_ptr->tag, tag, __ATOMIC_RELAXED);
1202 #else
1203  *(void *volatile *)&tagged_ptr->ptr = ptr;
1204  *(volatile size_t *)&tagged_ptr->tag = tag;
1205 #endif
1206 }
1207 
1208 static inline void ABTD_atomic_acquire_load_non_atomic_tagged_ptr(
1209  const ABTD_atomic_tagged_ptr *tagged_ptr, void **p_ptr, size_t *p_tag)
1210 {
1211 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1212 #ifndef __SUNPRO_C
1213  *p_ptr = __atomic_load_n(&tagged_ptr->ptr, __ATOMIC_ACQUIRE);
1214  *p_tag = __atomic_load_n(&tagged_ptr->tag, __ATOMIC_ACQUIRE);
1215 #else
1216  *p_ptr = __atomic_load_n((void **)&tagged_ptr->ptr, __ATOMIC_ACQUIRE);
1217  *p_tag = __atomic_load_n((size_t *)&tagged_ptr->tag, __ATOMIC_ACQUIRE);
1218 #endif
1219 #else
1220  __sync_synchronize();
1221  *p_ptr = *(void *volatile *)&tagged_ptr->ptr;
1222  *p_tag = *(volatile size_t *)&tagged_ptr->tag;
1223  __sync_synchronize();
1224 #endif
1225 }
1226 
1227 static inline void ABTD_atomic_release_store_non_atomic_tagged_ptr(
1228  ABTD_atomic_tagged_ptr *tagged_ptr, void *ptr, size_t tag)
1229 {
1230 #ifdef ABT_CONFIG_HAVE_ATOMIC_BUILTIN
1231  __atomic_store_n(&tagged_ptr->ptr, ptr, __ATOMIC_RELEASE);
1232  __atomic_store_n(&tagged_ptr->tag, tag, __ATOMIC_RELEASE);
1233 #else
1234  __sync_synchronize();
1235  *(void *volatile *)&tagged_ptr->ptr = ptr;
1236  *(volatile size_t *)&tagged_ptr->tag = tag;
1237  __sync_synchronize();
1238 #endif
1239 }
1240 
1241 #endif /* ABTD_ATOMIC_SUPPORT_TAGGED_PTR */
1242 
1243 #endif /* ABTD_ATOMIC_H_INCLUDED */
static void ABTD_atomic_release_clear_bool(ABTD_atomic_bool *ptr)
Definition: abtd_atomic.h:636
static uint64_t ABTD_atomic_val_cas_weak_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv)
Definition: abtd_atomic.h:245
static int ABTD_atomic_bool_cas_strong_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv)
Definition: abtd_atomic.h:366
static int64_t ABTD_atomic_val_cas_weak_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv)
Definition: abtd_atomic.h:239
static int32_t ABTD_atomic_acquire_load_int32(const ABTD_atomic_int32 *ptr)
Definition: abtd_atomic.h:780
static int ABTDI_atomic_bool_cas_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv, int weak)
Definition: abtd_atomic.h:161
static void * ABTD_atomic_acquire_load_ptr(const ABTD_atomic_ptr *ptr)
Definition: abtd_atomic.h:848
static void ABTD_atomic_release_store_uint64(ABTD_atomic_uint64 *ptr, uint64_t val)
Definition: abtd_atomic.h:971
static int64_t ABTD_atomic_acquire_load_int64(const ABTD_atomic_int64 *ptr)
Definition: abtd_atomic.h:814
static int ABTDI_atomic_bool_cas_int(ABTD_atomic_int *ptr, int oldv, int newv, int weak)
Definition: abtd_atomic.h:150
static int ABTD_atomic_bool_cas_strong_int(ABTD_atomic_int *ptr, int oldv, int newv)
Definition: abtd_atomic.h:334
static void ABTD_atomic_relaxed_store_ptr(ABTD_atomic_ptr *ptr, void *val)
Definition: abtd_atomic.h:914
static uint64_t ABTD_atomic_fetch_and_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:509
static int ABTD_atomic_bool_cas_strong_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv)
Definition: abtd_atomic.h:340
static void ABTD_atomic_release_store_int(ABTD_atomic_int *ptr, int val)
Definition: abtd_atomic.h:924
static uint64_t ABTD_atomic_val_cas_strong_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv)
Definition: abtd_atomic.h:286
static uint64_t ABTD_atomic_fetch_sub_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:460
static int ABTD_atomic_fetch_and_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:470
static int32_t ABTD_atomic_val_cas_weak_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv)
Definition: abtd_atomic.h:226
static int64_t ABTD_atomic_fetch_add_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:401
static int64_t ABTD_atomic_exchange_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:1036
static uint32_t ABTD_atomic_val_cas_strong_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv)
Definition: abtd_atomic.h:272
struct ABTD_atomic_int ABTD_atomic_int
static int ABTD_asm_bool_cas_weak_int128(__int128 *var, __int128 oldv, __int128 newv)
static void ABTD_atomic_release_store_uint32(ABTD_atomic_uint32 *ptr, uint32_t val)
Definition: abtd_atomic.h:947
static void * ABTD_atomic_relaxed_load_ptr(const ABTD_atomic_ptr *ptr)
Definition: abtd_atomic.h:731
struct ABTD_atomic_uint32 ABTD_atomic_uint32
static int64_t ABTD_atomic_relaxed_load_int64(const ABTD_atomic_int64 *ptr)
Definition: abtd_atomic.h:703
static int ABTD_atomic_fetch_or_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:519
int ABT_bool
Definition: abt.h:373
static uint64_t ABTD_atomic_relaxed_load_uint64(const ABTD_atomic_uint64 *ptr)
Definition: abtd_atomic.h:717
static uint64_t ABTDI_atomic_val_cas_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv, int weak)
Definition: abtd_atomic.h:123
static void ABTD_atomic_release_store_ptr(ABTD_atomic_ptr *ptr, void *val)
Definition: abtd_atomic.h:983
static void ABTD_atomic_relaxed_store_int64(ABTD_atomic_int64 *ptr, int64_t val)
Definition: abtd_atomic.h:894
static int ABTD_atomic_bool_cas_strong_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv)
Definition: abtd_atomic.h:353
static int ABTD_atomic_bool_cas_weak_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv)
Definition: abtd_atomic.h:328
static uint32_t ABTD_atomic_exchange_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:1022
static int ABTDI_atomic_bool_cas_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv, int weak)
Definition: abtd_atomic.h:173
static void * ABTD_atomic_val_cas_weak_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv)
Definition: abtd_atomic.h:252
static uint64_t ABTD_atomic_fetch_add_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:411
static void ABTD_atomic_relaxed_clear_bool(ABTD_atomic_bool *ptr)
Definition: abtd_atomic.h:627
static uint32_t ABTD_atomic_fetch_or_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:538
static int ABTD_atomic_bool_cas_strong_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv)
Definition: abtd_atomic.h:359
static uint32_t ABTD_atomic_fetch_add_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:391
static int64_t ABTD_atomic_fetch_and_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:499
#define ABT_FALSE
Definition: abt.h:285
static int64_t ABTDI_atomic_val_cas_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv, int weak)
Definition: abtd_atomic.h:109
static uint32_t ABTD_atomic_fetch_and_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:489
static uint32_t ABTD_atomic_acquire_load_uint32(const ABTD_atomic_uint32 *ptr)
Definition: abtd_atomic.h:797
static void ABTD_atomic_relaxed_store_int32(ABTD_atomic_int32 *ptr, int32_t val)
Definition: abtd_atomic.h:874
static int32_t ABTDI_atomic_val_cas_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv, int weak)
Definition: abtd_atomic.h:81
static int32_t ABTD_atomic_fetch_xor_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:577
static int32_t ABTD_atomic_fetch_or_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:528
static int32_t ABTD_atomic_fetch_and_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:479
static int ABTD_atomic_val_cas_strong_int(ABTD_atomic_int *ptr, int oldv, int newv)
Definition: abtd_atomic.h:258
static int ABTD_atomic_bool_cas_weak_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv)
Definition: abtd_atomic.h:310
struct ABTD_atomic_int64 ABTD_atomic_int64
static void ABTD_atomic_mem_barrier(void)
Definition: abtd_atomic.h:1077
#define ABT_TRUE
Definition: abt.h:284
static uint64_t ABTD_atomic_acquire_load_uint64(const ABTD_atomic_uint64 *ptr)
Definition: abtd_atomic.h:831
static int ABTDI_atomic_val_cas_int(ABTD_atomic_int *ptr, int oldv, int newv, int weak)
Definition: abtd_atomic.h:68
static int32_t ABTD_atomic_fetch_sub_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:430
static int ABTD_atomic_bool_cas_weak_int(ABTD_atomic_int *ptr, int oldv, int newv)
Definition: abtd_atomic.h:298
static int ABTD_atomic_val_cas_weak_int(ABTD_atomic_int *ptr, int oldv, int newv)
Definition: abtd_atomic.h:220
static uint32_t ABTDI_atomic_val_cas_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv, int weak)
Definition: abtd_atomic.h:95
static void ABTD_atomic_relaxed_store_uint32(ABTD_atomic_uint32 *ptr, uint32_t val)
Definition: abtd_atomic.h:884
static void * ABTDI_atomic_val_cas_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv, int weak)
Definition: abtd_atomic.h:137
static int32_t ABTD_atomic_fetch_add_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:381
static int64_t ABTD_atomic_fetch_sub_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:450
static int32_t ABTD_atomic_val_cas_strong_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv)
Definition: abtd_atomic.h:264
static void ABTD_atomic_relaxed_store_uint64(ABTD_atomic_uint64 *ptr, uint64_t val)
Definition: abtd_atomic.h:904
static uint64_t ABTD_atomic_fetch_or_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:558
struct ABTD_atomic_uint64 ABTD_atomic_uint64
static int64_t ABTD_atomic_val_cas_strong_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv)
Definition: abtd_atomic.h:278
static int64_t ABTD_atomic_fetch_xor_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:597
static int ABTD_atomic_bool_cas_weak_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv)
Definition: abtd_atomic.h:322
static uint32_t ABTD_atomic_fetch_sub_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:440
static int ABTD_atomic_bool_cas_strong_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv)
Definition: abtd_atomic.h:346
struct ABTD_atomic_bool ABTD_atomic_bool
static uint32_t ABTD_atomic_relaxed_load_uint32(const ABTD_atomic_uint32 *ptr)
Definition: abtd_atomic.h:689
static int ABTD_atomic_fetch_xor_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:568
static int ABTD_atomic_relaxed_load_int(const ABTD_atomic_int *ptr)
Definition: abtd_atomic.h:661
static int ABTD_atomic_fetch_sub_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:421
static int64_t ABTD_atomic_fetch_or_int64(ABTD_atomic_int64 *ptr, int64_t v)
Definition: abtd_atomic.h:548
static void ABTD_atomic_pause(void)
Definition: abtd_atomic.h:1091
struct ABTD_atomic_ptr ABTD_atomic_ptr
static int ABTD_atomic_bool_cas_weak_int32(ABTD_atomic_int32 *ptr, int32_t oldv, int32_t newv)
Definition: abtd_atomic.h:304
static void ABTD_atomic_relaxed_store_int(ABTD_atomic_int *ptr, int val)
Definition: abtd_atomic.h:865
static int32_t ABTD_atomic_relaxed_load_int32(const ABTD_atomic_int32 *ptr)
Definition: abtd_atomic.h:675
static void ABTD_compiler_barrier(void)
Definition: abtd_atomic.h:1086
static void * ABTD_atomic_val_cas_strong_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv)
Definition: abtd_atomic.h:292
static int ABTD_atomic_acquire_load_int(const ABTD_atomic_int *ptr)
Definition: abtd_atomic.h:763
static int ABTD_atomic_bool_cas_weak_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv)
Definition: abtd_atomic.h:316
static ABT_bool ABTD_atomic_relaxed_load_bool(const ABTD_atomic_bool *ptr)
Definition: abtd_atomic.h:646
static void ABTD_atomic_release_store_int32(ABTD_atomic_int32 *ptr, int32_t val)
Definition: abtd_atomic.h:935
static uint16_t ABTD_atomic_test_and_set_bool(ABTD_atomic_bool *ptr)
Definition: abtd_atomic.h:617
static uint32_t ABTD_atomic_val_cas_weak_uint32(ABTD_atomic_uint32 *ptr, uint32_t oldv, uint32_t newv)
Definition: abtd_atomic.h:232
static uint32_t ABTD_atomic_fetch_xor_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:587
static int ABTDI_atomic_bool_cas_int64(ABTD_atomic_int64 *ptr, int64_t oldv, int64_t newv, int weak)
Definition: abtd_atomic.h:185
static int ABTDI_atomic_bool_cas_ptr(ABTD_atomic_ptr *ptr, void *oldv, void *newv, int weak)
Definition: abtd_atomic.h:209
static int ABTD_atomic_fetch_add_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:372
static int ABTD_atomic_exchange_int(ABTD_atomic_int *ptr, int v)
Definition: abtd_atomic.h:995
static int32_t ABTD_atomic_exchange_int32(ABTD_atomic_int32 *ptr, int32_t v)
Definition: abtd_atomic.h:1008
struct ABTD_atomic_int32 ABTD_atomic_int32
#define ABTI_STATIC_ASSERT(cond)
Definition: abti_error.h:19
static void ABTD_atomic_release_store_int64(ABTD_atomic_int64 *ptr, int64_t val)
Definition: abtd_atomic.h:959
static uint64_t ABTD_atomic_fetch_xor_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:607
static ABT_bool ABTD_atomic_acquire_load_bool(const ABTD_atomic_bool *ptr)
Definition: abtd_atomic.h:746
static uint64_t ABTD_atomic_exchange_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:1050
static int ABTDI_atomic_bool_cas_uint64(ABTD_atomic_uint64 *ptr, uint64_t oldv, uint64_t newv, int weak)
Definition: abtd_atomic.h:197
static void * ABTD_atomic_exchange_ptr(ABTD_atomic_ptr *ptr, void *v)
Definition: abtd_atomic.h:1064