5 #ifndef ROC_CORE_ATOMIC_OPS_H_
6 #define ROC_CORE_ATOMIC_OPS_H_
10 #include <atomic_ops.h>
18 #ifdef AO_HAVE_nop_read
25 #ifdef AO_HAVE_nop_write
32 #ifdef AO_HAVE_nop_full
41 #ifdef AO_HAVE_char_load
43 static inline unsigned char load_relaxed(
unsigned char const& var) {
45 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
47 return (
unsigned char)AO_char_load((
unsigned char const*)&var);
51 #ifdef AO_HAVE_char_store
53 static inline void store_relaxed(
unsigned char& var,
unsigned char val) {
55 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
57 AO_char_store((
unsigned char*)&var, (
unsigned char)val);
61 #ifdef AO_HAVE_char_fetch_compare_and_swap
63 static inline unsigned char exchange_relaxed(
unsigned char& var,
unsigned char val) {
65 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
67 unsigned char curr = AO_char_load((
unsigned char*)&var);
71 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
73 }
while (curr != prev);
74 return (
unsigned char)curr;
78 #ifdef AO_HAVE_char_fetch_compare_and_swap
81 unsigned char& var,
unsigned char& exp,
unsigned char des) {
83 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
85 unsigned char old = AO_char_fetch_compare_and_swap(
86 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
87 const bool ret = ((
unsigned char)exp == old);
88 exp = (
unsigned char)old;
93 #ifdef AO_HAVE_char_fetch_and_add
95 static inline unsigned char fetch_add_relaxed(
unsigned char& var,
unsigned char val) {
97 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
99 return (
unsigned char)(
100 AO_char_fetch_and_add((
unsigned char*)&var, (
unsigned char)val));
104 #ifdef AO_HAVE_char_fetch_and_add
106 static inline unsigned char fetch_sub_relaxed(
unsigned char& var,
unsigned char val) {
108 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
110 return (
unsigned char)(
111 AO_char_fetch_and_add((
unsigned char*)&var, (
unsigned char)-val));
115 #ifdef AO_HAVE_char_fetch_compare_and_swap
117 static inline unsigned char fetch_and_relaxed(
unsigned char& var,
unsigned char val) {
119 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
121 unsigned char curr = AO_char_load((
unsigned char*)&var);
125 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
126 prev & (
unsigned char)val);
127 }
while (curr != prev);
128 return (
unsigned char)curr;
132 #ifdef AO_HAVE_char_fetch_compare_and_swap
134 static inline unsigned char fetch_or_relaxed(
unsigned char& var,
unsigned char val) {
136 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
138 unsigned char curr = AO_char_load((
unsigned char*)&var);
142 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
143 prev | (
unsigned char)val);
144 }
while (curr != prev);
145 return (
unsigned char)curr;
149 #ifdef AO_HAVE_char_fetch_compare_and_swap
151 static inline unsigned char fetch_xor_relaxed(
unsigned char& var,
unsigned char val) {
153 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
155 unsigned char curr = AO_char_load((
unsigned char*)&var);
159 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
160 prev ^ (
unsigned char)val);
161 }
while (curr != prev);
162 return (
unsigned char)curr;
166 #ifdef AO_HAVE_char_load_acquire
168 static inline unsigned char load_acquire(
unsigned char const& var) {
170 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
172 return (
unsigned char)AO_char_load_acquire((
unsigned char const*)&var);
176 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
178 static inline unsigned char exchange_acquire(
unsigned char& var,
unsigned char val) {
180 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
182 unsigned char curr = AO_char_load((
unsigned char*)&var);
186 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
188 }
while (curr != prev);
189 return (
unsigned char)curr;
193 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
196 unsigned char& var,
unsigned char& exp,
unsigned char des) {
198 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
200 unsigned char old = AO_char_fetch_compare_and_swap_acquire(
201 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
202 const bool ret = ((
unsigned char)exp == old);
203 exp = (
unsigned char)old;
208 #ifdef AO_HAVE_char_fetch_and_add_acquire
210 static inline unsigned char fetch_add_acquire(
unsigned char& var,
unsigned char val) {
212 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
214 return (
unsigned char)(
215 AO_char_fetch_and_add_acquire((
unsigned char*)&var, (
unsigned char)val));
219 #ifdef AO_HAVE_char_fetch_and_add_acquire
221 static inline unsigned char fetch_sub_acquire(
unsigned char& var,
unsigned char val) {
223 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
225 return (
unsigned char)(
226 AO_char_fetch_and_add_acquire((
unsigned char*)&var, (
unsigned char)-val));
230 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
232 static inline unsigned char fetch_and_acquire(
unsigned char& var,
unsigned char val) {
234 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
236 unsigned char curr = AO_char_load((
unsigned char*)&var);
240 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
241 prev & (
unsigned char)val);
242 }
while (curr != prev);
243 return (
unsigned char)curr;
247 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
249 static inline unsigned char fetch_or_acquire(
unsigned char& var,
unsigned char val) {
251 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
253 unsigned char curr = AO_char_load((
unsigned char*)&var);
257 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
258 prev | (
unsigned char)val);
259 }
while (curr != prev);
260 return (
unsigned char)curr;
264 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
266 static inline unsigned char fetch_xor_acquire(
unsigned char& var,
unsigned char val) {
268 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
270 unsigned char curr = AO_char_load((
unsigned char*)&var);
274 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
275 prev ^ (
unsigned char)val);
276 }
while (curr != prev);
277 return (
unsigned char)curr;
281 #ifdef AO_HAVE_char_store_release
283 static inline void store_release(
unsigned char& var,
unsigned char val) {
285 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
287 AO_char_store_release((
unsigned char*)&var, (
unsigned char)val);
291 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
293 static inline unsigned char exchange_release(
unsigned char& var,
unsigned char val) {
295 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
297 unsigned char curr = AO_char_load((
unsigned char*)&var);
301 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
303 }
while (curr != prev);
304 return (
unsigned char)curr;
308 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
311 unsigned char& var,
unsigned char& exp,
unsigned char des) {
313 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
315 unsigned char old = AO_char_fetch_compare_and_swap_release(
316 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
317 const bool ret = ((
unsigned char)exp == old);
318 exp = (
unsigned char)old;
323 #ifdef AO_HAVE_char_fetch_and_add_release
325 static inline unsigned char fetch_add_release(
unsigned char& var,
unsigned char val) {
327 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
329 return (
unsigned char)(
330 AO_char_fetch_and_add_release((
unsigned char*)&var, (
unsigned char)val));
334 #ifdef AO_HAVE_char_fetch_and_add_release
336 static inline unsigned char fetch_sub_release(
unsigned char& var,
unsigned char val) {
338 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
340 return (
unsigned char)(
341 AO_char_fetch_and_add_release((
unsigned char*)&var, (
unsigned char)-val));
345 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
347 static inline unsigned char fetch_and_release(
unsigned char& var,
unsigned char val) {
349 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
351 unsigned char curr = AO_char_load((
unsigned char*)&var);
355 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
356 prev & (
unsigned char)val);
357 }
while (curr != prev);
358 return (
unsigned char)curr;
362 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
364 static inline unsigned char fetch_or_release(
unsigned char& var,
unsigned char val) {
366 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
368 unsigned char curr = AO_char_load((
unsigned char*)&var);
372 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
373 prev | (
unsigned char)val);
374 }
while (curr != prev);
375 return (
unsigned char)curr;
379 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
381 static inline unsigned char fetch_xor_release(
unsigned char& var,
unsigned char val) {
383 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
385 unsigned char curr = AO_char_load((
unsigned char*)&var);
389 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
390 prev ^ (
unsigned char)val);
391 }
while (curr != prev);
392 return (
unsigned char)curr;
396 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
398 static inline unsigned char exchange_acq_rel(
unsigned char& var,
unsigned char val) {
400 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
402 unsigned char curr = AO_char_load((
unsigned char*)&var);
406 curr = AO_char_fetch_compare_and_swap_full((
unsigned char*)&var, prev,
408 }
while (curr != prev);
409 return (
unsigned char)curr;
413 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
416 unsigned char& var,
unsigned char& exp,
unsigned char des) {
418 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
420 unsigned char old = AO_char_fetch_compare_and_swap_full(
421 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
422 const bool ret = ((
unsigned char)exp == old);
423 exp = (
unsigned char)old;
428 #ifdef AO_HAVE_char_load_full
430 static inline unsigned char load_seq_cst(
unsigned char const& var) {
432 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
434 return (
unsigned char)AO_char_load_full((
unsigned char const*)&var);
438 #ifdef AO_HAVE_char_store_full
440 static inline void store_seq_cst(
unsigned char& var,
unsigned char val) {
442 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
444 AO_char_store_full((
unsigned char*)&var, (
unsigned char)val);
448 #ifdef AO_HAVE_char_fetch_compare_and_swap
450 static inline unsigned char exchange_seq_cst(
unsigned char& var,
unsigned char val) {
452 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
455 unsigned char curr = AO_char_load((
unsigned char*)&var);
459 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
462 }
while (curr != prev);
463 return (
unsigned char)curr;
467 #ifdef AO_HAVE_char_fetch_compare_and_swap
470 unsigned char& var,
unsigned char& exp,
unsigned char des) {
472 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
475 unsigned char old = AO_char_fetch_compare_and_swap(
476 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
477 const bool ret = ((
unsigned char)exp == old);
481 exp = (
unsigned char)old;
486 #ifdef AO_HAVE_char_fetch_and_add_full
488 static inline unsigned char fetch_add_seq_cst(
unsigned char& var,
unsigned char val) {
490 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
492 return (
unsigned char)(
493 AO_char_fetch_and_add_full((
unsigned char*)&var, (
unsigned char)val));
497 #ifdef AO_HAVE_char_fetch_and_add_full
499 static inline unsigned char fetch_sub_seq_cst(
unsigned char& var,
unsigned char val) {
501 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
503 return (
unsigned char)(
504 AO_char_fetch_and_add_full((
unsigned char*)&var, (
unsigned char)-val));
508 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
510 static inline unsigned char fetch_and_seq_cst(
unsigned char& var,
unsigned char val) {
512 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
515 unsigned char curr = AO_char_load((
unsigned char*)&var);
519 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
520 prev & (
unsigned char)val);
522 }
while (curr != prev);
523 return (
unsigned char)curr;
527 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
529 static inline unsigned char fetch_or_seq_cst(
unsigned char& var,
unsigned char val) {
531 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
534 unsigned char curr = AO_char_load((
unsigned char*)&var);
538 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
539 prev | (
unsigned char)val);
541 }
while (curr != prev);
542 return (
unsigned char)curr;
546 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
548 static inline unsigned char fetch_xor_seq_cst(
unsigned char& var,
unsigned char val) {
550 int f :
sizeof(
unsigned char) ==
sizeof(
unsigned char) ? 1 : -1;
553 unsigned char curr = AO_char_load((
unsigned char*)&var);
557 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
558 prev ^ (
unsigned char)val);
560 }
while (curr != prev);
561 return (
unsigned char)curr;
567 #ifdef AO_HAVE_char_load
571 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
573 return (
char)AO_char_load((
unsigned char const*)&var);
577 #ifdef AO_HAVE_char_store
581 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
583 AO_char_store((
unsigned char*)&var, (
unsigned char)val);
587 #ifdef AO_HAVE_char_fetch_compare_and_swap
591 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
593 unsigned char curr = AO_char_load((
unsigned char*)&var);
597 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
599 }
while (curr != prev);
604 #ifdef AO_HAVE_char_fetch_compare_and_swap
607 char& var,
char& exp,
char des) {
609 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
611 unsigned char old = AO_char_fetch_compare_and_swap(
612 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
613 const bool ret = ((
unsigned char)exp == old);
619 #ifdef AO_HAVE_char_fetch_and_add
623 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
626 AO_char_fetch_and_add((
unsigned char*)&var, (
unsigned char)val));
630 #ifdef AO_HAVE_char_fetch_and_add
634 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
637 AO_char_fetch_and_add((
unsigned char*)&var, (
unsigned char)-val));
641 #ifdef AO_HAVE_char_fetch_compare_and_swap
645 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
647 unsigned char curr = AO_char_load((
unsigned char*)&var);
651 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
652 prev & (
unsigned char)val);
653 }
while (curr != prev);
658 #ifdef AO_HAVE_char_fetch_compare_and_swap
662 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
664 unsigned char curr = AO_char_load((
unsigned char*)&var);
668 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
669 prev | (
unsigned char)val);
670 }
while (curr != prev);
675 #ifdef AO_HAVE_char_fetch_compare_and_swap
679 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
681 unsigned char curr = AO_char_load((
unsigned char*)&var);
685 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
686 prev ^ (
unsigned char)val);
687 }
while (curr != prev);
692 #ifdef AO_HAVE_char_load_acquire
696 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
698 return (
char)AO_char_load_acquire((
unsigned char const*)&var);
702 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
706 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
708 unsigned char curr = AO_char_load((
unsigned char*)&var);
712 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
714 }
while (curr != prev);
719 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
722 char& var,
char& exp,
char des) {
724 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
726 unsigned char old = AO_char_fetch_compare_and_swap_acquire(
727 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
728 const bool ret = ((
unsigned char)exp == old);
734 #ifdef AO_HAVE_char_fetch_and_add_acquire
738 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
741 AO_char_fetch_and_add_acquire((
unsigned char*)&var, (
unsigned char)val));
745 #ifdef AO_HAVE_char_fetch_and_add_acquire
749 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
752 AO_char_fetch_and_add_acquire((
unsigned char*)&var, (
unsigned char)-val));
756 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
760 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
762 unsigned char curr = AO_char_load((
unsigned char*)&var);
766 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
767 prev & (
unsigned char)val);
768 }
while (curr != prev);
773 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
777 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
779 unsigned char curr = AO_char_load((
unsigned char*)&var);
783 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
784 prev | (
unsigned char)val);
785 }
while (curr != prev);
790 #ifdef AO_HAVE_char_fetch_compare_and_swap_acquire
794 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
796 unsigned char curr = AO_char_load((
unsigned char*)&var);
800 curr = AO_char_fetch_compare_and_swap_acquire((
unsigned char*)&var, prev,
801 prev ^ (
unsigned char)val);
802 }
while (curr != prev);
807 #ifdef AO_HAVE_char_store_release
811 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
813 AO_char_store_release((
unsigned char*)&var, (
unsigned char)val);
817 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
821 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
823 unsigned char curr = AO_char_load((
unsigned char*)&var);
827 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
829 }
while (curr != prev);
834 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
837 char& var,
char& exp,
char des) {
839 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
841 unsigned char old = AO_char_fetch_compare_and_swap_release(
842 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
843 const bool ret = ((
unsigned char)exp == old);
849 #ifdef AO_HAVE_char_fetch_and_add_release
853 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
856 AO_char_fetch_and_add_release((
unsigned char*)&var, (
unsigned char)val));
860 #ifdef AO_HAVE_char_fetch_and_add_release
864 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
867 AO_char_fetch_and_add_release((
unsigned char*)&var, (
unsigned char)-val));
871 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
875 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
877 unsigned char curr = AO_char_load((
unsigned char*)&var);
881 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
882 prev & (
unsigned char)val);
883 }
while (curr != prev);
888 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
892 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
894 unsigned char curr = AO_char_load((
unsigned char*)&var);
898 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
899 prev | (
unsigned char)val);
900 }
while (curr != prev);
905 #ifdef AO_HAVE_char_fetch_compare_and_swap_release
909 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
911 unsigned char curr = AO_char_load((
unsigned char*)&var);
915 curr = AO_char_fetch_compare_and_swap_release((
unsigned char*)&var, prev,
916 prev ^ (
unsigned char)val);
917 }
while (curr != prev);
922 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
926 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
928 unsigned char curr = AO_char_load((
unsigned char*)&var);
932 curr = AO_char_fetch_compare_and_swap_full((
unsigned char*)&var, prev,
934 }
while (curr != prev);
939 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
942 char& var,
char& exp,
char des) {
944 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
946 unsigned char old = AO_char_fetch_compare_and_swap_full(
947 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
948 const bool ret = ((
unsigned char)exp == old);
954 #ifdef AO_HAVE_char_load_full
958 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
960 return (
char)AO_char_load_full((
unsigned char const*)&var);
964 #ifdef AO_HAVE_char_store_full
968 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
970 AO_char_store_full((
unsigned char*)&var, (
unsigned char)val);
974 #ifdef AO_HAVE_char_fetch_compare_and_swap
978 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
981 unsigned char curr = AO_char_load((
unsigned char*)&var);
985 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
988 }
while (curr != prev);
993 #ifdef AO_HAVE_char_fetch_compare_and_swap
996 char& var,
char& exp,
char des) {
998 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1001 unsigned char old = AO_char_fetch_compare_and_swap(
1002 (
unsigned char*)&var, (
unsigned char)exp, (
unsigned char)des);
1003 const bool ret = ((
unsigned char)exp == old);
1012 #ifdef AO_HAVE_char_fetch_and_add_full
1016 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1019 AO_char_fetch_and_add_full((
unsigned char*)&var, (
unsigned char)val));
1023 #ifdef AO_HAVE_char_fetch_and_add_full
1027 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1030 AO_char_fetch_and_add_full((
unsigned char*)&var, (
unsigned char)-val));
1034 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
1038 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1041 unsigned char curr = AO_char_load((
unsigned char*)&var);
1045 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
1046 prev & (
unsigned char)val);
1048 }
while (curr != prev);
1053 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
1057 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1060 unsigned char curr = AO_char_load((
unsigned char*)&var);
1064 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
1065 prev | (
unsigned char)val);
1067 }
while (curr != prev);
1072 #ifdef AO_HAVE_char_fetch_compare_and_swap_full
1076 int f :
sizeof(char) ==
sizeof(
unsigned char) ? 1 : -1;
1079 unsigned char curr = AO_char_load((
unsigned char*)&var);
1083 curr = AO_char_fetch_compare_and_swap((
unsigned char*)&var, prev,
1084 prev ^ (
unsigned char)val);
1086 }
while (curr != prev);
1093 #ifdef AO_HAVE_short_load
1095 static inline unsigned short load_relaxed(
unsigned short const& var) {
1097 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1099 return (
unsigned short)AO_short_load((
unsigned short const*)&var);
1103 #ifdef AO_HAVE_short_store
1105 static inline void store_relaxed(
unsigned short& var,
unsigned short val) {
1107 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1109 AO_short_store((
unsigned short*)&var, (
unsigned short)val);
1113 #ifdef AO_HAVE_short_fetch_compare_and_swap
1115 static inline unsigned short exchange_relaxed(
unsigned short& var,
unsigned short val) {
1117 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1119 unsigned short curr = AO_short_load((
unsigned short*)&var);
1120 unsigned short prev;
1123 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1124 (
unsigned short)val);
1125 }
while (curr != prev);
1126 return (
unsigned short)curr;
1130 #ifdef AO_HAVE_short_fetch_compare_and_swap
1133 unsigned short& var,
unsigned short& exp,
unsigned short des) {
1135 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1137 unsigned short old = AO_short_fetch_compare_and_swap(
1138 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1139 const bool ret = ((
unsigned short)exp == old);
1140 exp = (
unsigned short)old;
1145 #ifdef AO_HAVE_short_fetch_and_add
1147 static inline unsigned short fetch_add_relaxed(
unsigned short& var,
unsigned short val) {
1149 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1151 return (
unsigned short)(
1152 AO_short_fetch_and_add((
unsigned short*)&var, (
unsigned short)val));
1156 #ifdef AO_HAVE_short_fetch_and_add
1158 static inline unsigned short fetch_sub_relaxed(
unsigned short& var,
unsigned short val) {
1160 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1162 return (
unsigned short)(
1163 AO_short_fetch_and_add((
unsigned short*)&var, (
unsigned short)-val));
1167 #ifdef AO_HAVE_short_fetch_compare_and_swap
1169 static inline unsigned short fetch_and_relaxed(
unsigned short& var,
unsigned short val) {
1171 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1173 unsigned short curr = AO_short_load((
unsigned short*)&var);
1174 unsigned short prev;
1177 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1178 prev & (
unsigned short)val);
1179 }
while (curr != prev);
1180 return (
unsigned short)curr;
1184 #ifdef AO_HAVE_short_fetch_compare_and_swap
1186 static inline unsigned short fetch_or_relaxed(
unsigned short& var,
unsigned short val) {
1188 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1190 unsigned short curr = AO_short_load((
unsigned short*)&var);
1191 unsigned short prev;
1194 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1195 prev | (
unsigned short)val);
1196 }
while (curr != prev);
1197 return (
unsigned short)curr;
1201 #ifdef AO_HAVE_short_fetch_compare_and_swap
1203 static inline unsigned short fetch_xor_relaxed(
unsigned short& var,
unsigned short val) {
1205 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1207 unsigned short curr = AO_short_load((
unsigned short*)&var);
1208 unsigned short prev;
1211 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1212 prev ^ (
unsigned short)val);
1213 }
while (curr != prev);
1214 return (
unsigned short)curr;
1218 #ifdef AO_HAVE_short_load_acquire
1220 static inline unsigned short load_acquire(
unsigned short const& var) {
1222 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1224 return (
unsigned short)AO_short_load_acquire((
unsigned short const*)&var);
1228 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1230 static inline unsigned short exchange_acquire(
unsigned short& var,
unsigned short val) {
1232 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1234 unsigned short curr = AO_short_load((
unsigned short*)&var);
1235 unsigned short prev;
1238 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1239 (
unsigned short)val);
1240 }
while (curr != prev);
1241 return (
unsigned short)curr;
1245 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1248 unsigned short& var,
unsigned short& exp,
unsigned short des) {
1250 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1252 unsigned short old = AO_short_fetch_compare_and_swap_acquire(
1253 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1254 const bool ret = ((
unsigned short)exp == old);
1255 exp = (
unsigned short)old;
1260 #ifdef AO_HAVE_short_fetch_and_add_acquire
1262 static inline unsigned short fetch_add_acquire(
unsigned short& var,
unsigned short val) {
1264 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1266 return (
unsigned short)(
1267 AO_short_fetch_and_add_acquire((
unsigned short*)&var, (
unsigned short)val));
1271 #ifdef AO_HAVE_short_fetch_and_add_acquire
1273 static inline unsigned short fetch_sub_acquire(
unsigned short& var,
unsigned short val) {
1275 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1277 return (
unsigned short)(
1278 AO_short_fetch_and_add_acquire((
unsigned short*)&var, (
unsigned short)-val));
1282 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1284 static inline unsigned short fetch_and_acquire(
unsigned short& var,
unsigned short val) {
1286 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1288 unsigned short curr = AO_short_load((
unsigned short*)&var);
1289 unsigned short prev;
1292 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1293 prev & (
unsigned short)val);
1294 }
while (curr != prev);
1295 return (
unsigned short)curr;
1299 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1301 static inline unsigned short fetch_or_acquire(
unsigned short& var,
unsigned short val) {
1303 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1305 unsigned short curr = AO_short_load((
unsigned short*)&var);
1306 unsigned short prev;
1309 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1310 prev | (
unsigned short)val);
1311 }
while (curr != prev);
1312 return (
unsigned short)curr;
1316 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1318 static inline unsigned short fetch_xor_acquire(
unsigned short& var,
unsigned short val) {
1320 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1322 unsigned short curr = AO_short_load((
unsigned short*)&var);
1323 unsigned short prev;
1326 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1327 prev ^ (
unsigned short)val);
1328 }
while (curr != prev);
1329 return (
unsigned short)curr;
1333 #ifdef AO_HAVE_short_store_release
1335 static inline void store_release(
unsigned short& var,
unsigned short val) {
1337 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1339 AO_short_store_release((
unsigned short*)&var, (
unsigned short)val);
1343 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1345 static inline unsigned short exchange_release(
unsigned short& var,
unsigned short val) {
1347 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1349 unsigned short curr = AO_short_load((
unsigned short*)&var);
1350 unsigned short prev;
1353 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1354 (
unsigned short)val);
1355 }
while (curr != prev);
1356 return (
unsigned short)curr;
1360 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1363 unsigned short& var,
unsigned short& exp,
unsigned short des) {
1365 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1367 unsigned short old = AO_short_fetch_compare_and_swap_release(
1368 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1369 const bool ret = ((
unsigned short)exp == old);
1370 exp = (
unsigned short)old;
1375 #ifdef AO_HAVE_short_fetch_and_add_release
1377 static inline unsigned short fetch_add_release(
unsigned short& var,
unsigned short val) {
1379 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1381 return (
unsigned short)(
1382 AO_short_fetch_and_add_release((
unsigned short*)&var, (
unsigned short)val));
1386 #ifdef AO_HAVE_short_fetch_and_add_release
1388 static inline unsigned short fetch_sub_release(
unsigned short& var,
unsigned short val) {
1390 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1392 return (
unsigned short)(
1393 AO_short_fetch_and_add_release((
unsigned short*)&var, (
unsigned short)-val));
1397 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1399 static inline unsigned short fetch_and_release(
unsigned short& var,
unsigned short val) {
1401 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1403 unsigned short curr = AO_short_load((
unsigned short*)&var);
1404 unsigned short prev;
1407 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1408 prev & (
unsigned short)val);
1409 }
while (curr != prev);
1410 return (
unsigned short)curr;
1414 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1416 static inline unsigned short fetch_or_release(
unsigned short& var,
unsigned short val) {
1418 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1420 unsigned short curr = AO_short_load((
unsigned short*)&var);
1421 unsigned short prev;
1424 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1425 prev | (
unsigned short)val);
1426 }
while (curr != prev);
1427 return (
unsigned short)curr;
1431 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1433 static inline unsigned short fetch_xor_release(
unsigned short& var,
unsigned short val) {
1435 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1437 unsigned short curr = AO_short_load((
unsigned short*)&var);
1438 unsigned short prev;
1441 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1442 prev ^ (
unsigned short)val);
1443 }
while (curr != prev);
1444 return (
unsigned short)curr;
1448 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1450 static inline unsigned short exchange_acq_rel(
unsigned short& var,
unsigned short val) {
1452 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1454 unsigned short curr = AO_short_load((
unsigned short*)&var);
1455 unsigned short prev;
1458 curr = AO_short_fetch_compare_and_swap_full((
unsigned short*)&var, prev,
1459 (
unsigned short)val);
1460 }
while (curr != prev);
1461 return (
unsigned short)curr;
1465 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1468 unsigned short& var,
unsigned short& exp,
unsigned short des) {
1470 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1472 unsigned short old = AO_short_fetch_compare_and_swap_full(
1473 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1474 const bool ret = ((
unsigned short)exp == old);
1475 exp = (
unsigned short)old;
1480 #ifdef AO_HAVE_short_load_full
1482 static inline unsigned short load_seq_cst(
unsigned short const& var) {
1484 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1486 return (
unsigned short)AO_short_load_full((
unsigned short const*)&var);
1490 #ifdef AO_HAVE_short_store_full
1492 static inline void store_seq_cst(
unsigned short& var,
unsigned short val) {
1494 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1496 AO_short_store_full((
unsigned short*)&var, (
unsigned short)val);
1500 #ifdef AO_HAVE_short_fetch_compare_and_swap
1502 static inline unsigned short exchange_seq_cst(
unsigned short& var,
unsigned short val) {
1504 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1507 unsigned short curr = AO_short_load((
unsigned short*)&var);
1508 unsigned short prev;
1511 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1512 (
unsigned short)val);
1514 }
while (curr != prev);
1515 return (
unsigned short)curr;
1519 #ifdef AO_HAVE_short_fetch_compare_and_swap
1522 unsigned short& var,
unsigned short& exp,
unsigned short des) {
1524 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1527 unsigned short old = AO_short_fetch_compare_and_swap(
1528 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1529 const bool ret = ((
unsigned short)exp == old);
1533 exp = (
unsigned short)old;
1538 #ifdef AO_HAVE_short_fetch_and_add_full
1540 static inline unsigned short fetch_add_seq_cst(
unsigned short& var,
unsigned short val) {
1542 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1544 return (
unsigned short)(
1545 AO_short_fetch_and_add_full((
unsigned short*)&var, (
unsigned short)val));
1549 #ifdef AO_HAVE_short_fetch_and_add_full
1551 static inline unsigned short fetch_sub_seq_cst(
unsigned short& var,
unsigned short val) {
1553 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1555 return (
unsigned short)(
1556 AO_short_fetch_and_add_full((
unsigned short*)&var, (
unsigned short)-val));
1560 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1562 static inline unsigned short fetch_and_seq_cst(
unsigned short& var,
unsigned short val) {
1564 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1567 unsigned short curr = AO_short_load((
unsigned short*)&var);
1568 unsigned short prev;
1571 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1572 prev & (
unsigned short)val);
1574 }
while (curr != prev);
1575 return (
unsigned short)curr;
1579 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1581 static inline unsigned short fetch_or_seq_cst(
unsigned short& var,
unsigned short val) {
1583 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1586 unsigned short curr = AO_short_load((
unsigned short*)&var);
1587 unsigned short prev;
1590 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1591 prev | (
unsigned short)val);
1593 }
while (curr != prev);
1594 return (
unsigned short)curr;
1598 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1600 static inline unsigned short fetch_xor_seq_cst(
unsigned short& var,
unsigned short val) {
1602 int f :
sizeof(
unsigned short) ==
sizeof(
unsigned short) ? 1 : -1;
1605 unsigned short curr = AO_short_load((
unsigned short*)&var);
1606 unsigned short prev;
1609 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1610 prev ^ (
unsigned short)val);
1612 }
while (curr != prev);
1613 return (
unsigned short)curr;
1619 #ifdef AO_HAVE_short_load
1623 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1625 return (
short)AO_short_load((
unsigned short const*)&var);
1629 #ifdef AO_HAVE_short_store
1633 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1635 AO_short_store((
unsigned short*)&var, (
unsigned short)val);
1639 #ifdef AO_HAVE_short_fetch_compare_and_swap
1643 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1645 unsigned short curr = AO_short_load((
unsigned short*)&var);
1646 unsigned short prev;
1649 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1650 (
unsigned short)val);
1651 }
while (curr != prev);
1656 #ifdef AO_HAVE_short_fetch_compare_and_swap
1659 short& var,
short& exp,
short des) {
1661 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1663 unsigned short old = AO_short_fetch_compare_and_swap(
1664 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1665 const bool ret = ((
unsigned short)exp == old);
1671 #ifdef AO_HAVE_short_fetch_and_add
1675 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1678 AO_short_fetch_and_add((
unsigned short*)&var, (
unsigned short)val));
1682 #ifdef AO_HAVE_short_fetch_and_add
1686 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1689 AO_short_fetch_and_add((
unsigned short*)&var, (
unsigned short)-val));
1693 #ifdef AO_HAVE_short_fetch_compare_and_swap
1697 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1699 unsigned short curr = AO_short_load((
unsigned short*)&var);
1700 unsigned short prev;
1703 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1704 prev & (
unsigned short)val);
1705 }
while (curr != prev);
1710 #ifdef AO_HAVE_short_fetch_compare_and_swap
1714 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1716 unsigned short curr = AO_short_load((
unsigned short*)&var);
1717 unsigned short prev;
1720 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1721 prev | (
unsigned short)val);
1722 }
while (curr != prev);
1727 #ifdef AO_HAVE_short_fetch_compare_and_swap
1731 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1733 unsigned short curr = AO_short_load((
unsigned short*)&var);
1734 unsigned short prev;
1737 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
1738 prev ^ (
unsigned short)val);
1739 }
while (curr != prev);
1744 #ifdef AO_HAVE_short_load_acquire
1748 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1750 return (
short)AO_short_load_acquire((
unsigned short const*)&var);
1754 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1758 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1760 unsigned short curr = AO_short_load((
unsigned short*)&var);
1761 unsigned short prev;
1764 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1765 (
unsigned short)val);
1766 }
while (curr != prev);
1771 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1774 short& var,
short& exp,
short des) {
1776 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1778 unsigned short old = AO_short_fetch_compare_and_swap_acquire(
1779 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1780 const bool ret = ((
unsigned short)exp == old);
1786 #ifdef AO_HAVE_short_fetch_and_add_acquire
1790 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1793 AO_short_fetch_and_add_acquire((
unsigned short*)&var, (
unsigned short)val));
1797 #ifdef AO_HAVE_short_fetch_and_add_acquire
1801 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1804 AO_short_fetch_and_add_acquire((
unsigned short*)&var, (
unsigned short)-val));
1808 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1812 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1814 unsigned short curr = AO_short_load((
unsigned short*)&var);
1815 unsigned short prev;
1818 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1819 prev & (
unsigned short)val);
1820 }
while (curr != prev);
1825 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1829 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1831 unsigned short curr = AO_short_load((
unsigned short*)&var);
1832 unsigned short prev;
1835 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1836 prev | (
unsigned short)val);
1837 }
while (curr != prev);
1842 #ifdef AO_HAVE_short_fetch_compare_and_swap_acquire
1846 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1848 unsigned short curr = AO_short_load((
unsigned short*)&var);
1849 unsigned short prev;
1852 curr = AO_short_fetch_compare_and_swap_acquire((
unsigned short*)&var, prev,
1853 prev ^ (
unsigned short)val);
1854 }
while (curr != prev);
1859 #ifdef AO_HAVE_short_store_release
1863 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1865 AO_short_store_release((
unsigned short*)&var, (
unsigned short)val);
1869 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1873 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1875 unsigned short curr = AO_short_load((
unsigned short*)&var);
1876 unsigned short prev;
1879 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1880 (
unsigned short)val);
1881 }
while (curr != prev);
1886 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1889 short& var,
short& exp,
short des) {
1891 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1893 unsigned short old = AO_short_fetch_compare_and_swap_release(
1894 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
1895 const bool ret = ((
unsigned short)exp == old);
1901 #ifdef AO_HAVE_short_fetch_and_add_release
1905 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1908 AO_short_fetch_and_add_release((
unsigned short*)&var, (
unsigned short)val));
1912 #ifdef AO_HAVE_short_fetch_and_add_release
1916 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1919 AO_short_fetch_and_add_release((
unsigned short*)&var, (
unsigned short)-val));
1923 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1927 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1929 unsigned short curr = AO_short_load((
unsigned short*)&var);
1930 unsigned short prev;
1933 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1934 prev & (
unsigned short)val);
1935 }
while (curr != prev);
1940 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1944 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1946 unsigned short curr = AO_short_load((
unsigned short*)&var);
1947 unsigned short prev;
1950 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1951 prev | (
unsigned short)val);
1952 }
while (curr != prev);
1957 #ifdef AO_HAVE_short_fetch_compare_and_swap_release
1961 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1963 unsigned short curr = AO_short_load((
unsigned short*)&var);
1964 unsigned short prev;
1967 curr = AO_short_fetch_compare_and_swap_release((
unsigned short*)&var, prev,
1968 prev ^ (
unsigned short)val);
1969 }
while (curr != prev);
1974 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1978 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1980 unsigned short curr = AO_short_load((
unsigned short*)&var);
1981 unsigned short prev;
1984 curr = AO_short_fetch_compare_and_swap_full((
unsigned short*)&var, prev,
1985 (
unsigned short)val);
1986 }
while (curr != prev);
1991 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
1994 short& var,
short& exp,
short des) {
1996 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
1998 unsigned short old = AO_short_fetch_compare_and_swap_full(
1999 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
2000 const bool ret = ((
unsigned short)exp == old);
2006 #ifdef AO_HAVE_short_load_full
2010 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2012 return (
short)AO_short_load_full((
unsigned short const*)&var);
2016 #ifdef AO_HAVE_short_store_full
2020 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2022 AO_short_store_full((
unsigned short*)&var, (
unsigned short)val);
2026 #ifdef AO_HAVE_short_fetch_compare_and_swap
2030 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2033 unsigned short curr = AO_short_load((
unsigned short*)&var);
2034 unsigned short prev;
2037 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
2038 (
unsigned short)val);
2040 }
while (curr != prev);
2045 #ifdef AO_HAVE_short_fetch_compare_and_swap
2048 short& var,
short& exp,
short des) {
2050 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2053 unsigned short old = AO_short_fetch_compare_and_swap(
2054 (
unsigned short*)&var, (
unsigned short)exp, (
unsigned short)des);
2055 const bool ret = ((
unsigned short)exp == old);
2064 #ifdef AO_HAVE_short_fetch_and_add_full
2068 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2071 AO_short_fetch_and_add_full((
unsigned short*)&var, (
unsigned short)val));
2075 #ifdef AO_HAVE_short_fetch_and_add_full
2079 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2082 AO_short_fetch_and_add_full((
unsigned short*)&var, (
unsigned short)-val));
2086 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
2090 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2093 unsigned short curr = AO_short_load((
unsigned short*)&var);
2094 unsigned short prev;
2097 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
2098 prev & (
unsigned short)val);
2100 }
while (curr != prev);
2105 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
2109 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2112 unsigned short curr = AO_short_load((
unsigned short*)&var);
2113 unsigned short prev;
2116 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
2117 prev | (
unsigned short)val);
2119 }
while (curr != prev);
2124 #ifdef AO_HAVE_short_fetch_compare_and_swap_full
2128 int f :
sizeof(short) ==
sizeof(
unsigned short) ? 1 : -1;
2131 unsigned short curr = AO_short_load((
unsigned short*)&var);
2132 unsigned short prev;
2135 curr = AO_short_fetch_compare_and_swap((
unsigned short*)&var, prev,
2136 prev ^ (
unsigned short)val);
2138 }
while (curr != prev);
2147 #ifdef AO_HAVE_int_load
2149 static inline unsigned int load_relaxed(
unsigned int const& var) {
2151 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2153 return (
unsigned int)AO_int_load((
unsigned int const*)&var);
2157 #ifdef AO_HAVE_int_store
2159 static inline void store_relaxed(
unsigned int& var,
unsigned int val) {
2161 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2163 AO_int_store((
unsigned int*)&var, (
unsigned int)val);
2167 #ifdef AO_HAVE_int_fetch_compare_and_swap
2169 static inline unsigned int exchange_relaxed(
unsigned int& var,
unsigned int val) {
2171 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2173 unsigned int curr = AO_int_load((
unsigned int*)&var);
2177 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2179 }
while (curr != prev);
2180 return (
unsigned int)curr;
2184 #ifdef AO_HAVE_int_fetch_compare_and_swap
2187 unsigned int& var,
unsigned int& exp,
unsigned int des) {
2189 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2191 unsigned int old = AO_int_fetch_compare_and_swap(
2192 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2193 const bool ret = ((
unsigned int)exp == old);
2194 exp = (
unsigned int)old;
2199 #ifdef AO_HAVE_int_fetch_and_add
2201 static inline unsigned int fetch_add_relaxed(
unsigned int& var,
unsigned int val) {
2203 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2205 return (
unsigned int)(
2206 AO_int_fetch_and_add((
unsigned int*)&var, (
unsigned int)val));
2210 #ifdef AO_HAVE_int_fetch_and_add
2212 static inline unsigned int fetch_sub_relaxed(
unsigned int& var,
unsigned int val) {
2214 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2216 return (
unsigned int)(
2217 AO_int_fetch_and_add((
unsigned int*)&var, (
unsigned int)-val));
2221 #ifdef AO_HAVE_int_fetch_compare_and_swap
2223 static inline unsigned int fetch_and_relaxed(
unsigned int& var,
unsigned int val) {
2225 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2227 unsigned int curr = AO_int_load((
unsigned int*)&var);
2231 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2232 prev & (
unsigned int)val);
2233 }
while (curr != prev);
2234 return (
unsigned int)curr;
2238 #ifdef AO_HAVE_int_fetch_compare_and_swap
2240 static inline unsigned int fetch_or_relaxed(
unsigned int& var,
unsigned int val) {
2242 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2244 unsigned int curr = AO_int_load((
unsigned int*)&var);
2248 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2249 prev | (
unsigned int)val);
2250 }
while (curr != prev);
2251 return (
unsigned int)curr;
2255 #ifdef AO_HAVE_int_fetch_compare_and_swap
2257 static inline unsigned int fetch_xor_relaxed(
unsigned int& var,
unsigned int val) {
2259 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2261 unsigned int curr = AO_int_load((
unsigned int*)&var);
2265 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2266 prev ^ (
unsigned int)val);
2267 }
while (curr != prev);
2268 return (
unsigned int)curr;
2272 #ifdef AO_HAVE_int_load_acquire
2274 static inline unsigned int load_acquire(
unsigned int const& var) {
2276 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2278 return (
unsigned int)AO_int_load_acquire((
unsigned int const*)&var);
2282 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2284 static inline unsigned int exchange_acquire(
unsigned int& var,
unsigned int val) {
2286 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2288 unsigned int curr = AO_int_load((
unsigned int*)&var);
2292 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2294 }
while (curr != prev);
2295 return (
unsigned int)curr;
2299 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2302 unsigned int& var,
unsigned int& exp,
unsigned int des) {
2304 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2306 unsigned int old = AO_int_fetch_compare_and_swap_acquire(
2307 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2308 const bool ret = ((
unsigned int)exp == old);
2309 exp = (
unsigned int)old;
2314 #ifdef AO_HAVE_int_fetch_and_add_acquire
2316 static inline unsigned int fetch_add_acquire(
unsigned int& var,
unsigned int val) {
2318 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2320 return (
unsigned int)(
2321 AO_int_fetch_and_add_acquire((
unsigned int*)&var, (
unsigned int)val));
2325 #ifdef AO_HAVE_int_fetch_and_add_acquire
2327 static inline unsigned int fetch_sub_acquire(
unsigned int& var,
unsigned int val) {
2329 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2331 return (
unsigned int)(
2332 AO_int_fetch_and_add_acquire((
unsigned int*)&var, (
unsigned int)-val));
2336 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2338 static inline unsigned int fetch_and_acquire(
unsigned int& var,
unsigned int val) {
2340 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2342 unsigned int curr = AO_int_load((
unsigned int*)&var);
2346 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2347 prev & (
unsigned int)val);
2348 }
while (curr != prev);
2349 return (
unsigned int)curr;
2353 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2355 static inline unsigned int fetch_or_acquire(
unsigned int& var,
unsigned int val) {
2357 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2359 unsigned int curr = AO_int_load((
unsigned int*)&var);
2363 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2364 prev | (
unsigned int)val);
2365 }
while (curr != prev);
2366 return (
unsigned int)curr;
2370 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2372 static inline unsigned int fetch_xor_acquire(
unsigned int& var,
unsigned int val) {
2374 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2376 unsigned int curr = AO_int_load((
unsigned int*)&var);
2380 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2381 prev ^ (
unsigned int)val);
2382 }
while (curr != prev);
2383 return (
unsigned int)curr;
2387 #ifdef AO_HAVE_int_store_release
2389 static inline void store_release(
unsigned int& var,
unsigned int val) {
2391 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2393 AO_int_store_release((
unsigned int*)&var, (
unsigned int)val);
2397 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2399 static inline unsigned int exchange_release(
unsigned int& var,
unsigned int val) {
2401 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2403 unsigned int curr = AO_int_load((
unsigned int*)&var);
2407 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2409 }
while (curr != prev);
2410 return (
unsigned int)curr;
2414 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2417 unsigned int& var,
unsigned int& exp,
unsigned int des) {
2419 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2421 unsigned int old = AO_int_fetch_compare_and_swap_release(
2422 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2423 const bool ret = ((
unsigned int)exp == old);
2424 exp = (
unsigned int)old;
2429 #ifdef AO_HAVE_int_fetch_and_add_release
2431 static inline unsigned int fetch_add_release(
unsigned int& var,
unsigned int val) {
2433 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2435 return (
unsigned int)(
2436 AO_int_fetch_and_add_release((
unsigned int*)&var, (
unsigned int)val));
2440 #ifdef AO_HAVE_int_fetch_and_add_release
2442 static inline unsigned int fetch_sub_release(
unsigned int& var,
unsigned int val) {
2444 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2446 return (
unsigned int)(
2447 AO_int_fetch_and_add_release((
unsigned int*)&var, (
unsigned int)-val));
2451 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2453 static inline unsigned int fetch_and_release(
unsigned int& var,
unsigned int val) {
2455 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2457 unsigned int curr = AO_int_load((
unsigned int*)&var);
2461 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2462 prev & (
unsigned int)val);
2463 }
while (curr != prev);
2464 return (
unsigned int)curr;
2468 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2470 static inline unsigned int fetch_or_release(
unsigned int& var,
unsigned int val) {
2472 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2474 unsigned int curr = AO_int_load((
unsigned int*)&var);
2478 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2479 prev | (
unsigned int)val);
2480 }
while (curr != prev);
2481 return (
unsigned int)curr;
2485 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2487 static inline unsigned int fetch_xor_release(
unsigned int& var,
unsigned int val) {
2489 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2491 unsigned int curr = AO_int_load((
unsigned int*)&var);
2495 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2496 prev ^ (
unsigned int)val);
2497 }
while (curr != prev);
2498 return (
unsigned int)curr;
2502 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
2504 static inline unsigned int exchange_acq_rel(
unsigned int& var,
unsigned int val) {
2506 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2508 unsigned int curr = AO_int_load((
unsigned int*)&var);
2512 curr = AO_int_fetch_compare_and_swap_full((
unsigned int*)&var, prev,
2514 }
while (curr != prev);
2515 return (
unsigned int)curr;
2519 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
2522 unsigned int& var,
unsigned int& exp,
unsigned int des) {
2524 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2526 unsigned int old = AO_int_fetch_compare_and_swap_full(
2527 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2528 const bool ret = ((
unsigned int)exp == old);
2529 exp = (
unsigned int)old;
2534 #ifdef AO_HAVE_int_load_full
2536 static inline unsigned int load_seq_cst(
unsigned int const& var) {
2538 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2540 return (
unsigned int)AO_int_load_full((
unsigned int const*)&var);
2544 #ifdef AO_HAVE_int_store_full
2546 static inline void store_seq_cst(
unsigned int& var,
unsigned int val) {
2548 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2550 AO_int_store_full((
unsigned int*)&var, (
unsigned int)val);
2554 #ifdef AO_HAVE_int_fetch_compare_and_swap
2556 static inline unsigned int exchange_seq_cst(
unsigned int& var,
unsigned int val) {
2558 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2561 unsigned int curr = AO_int_load((
unsigned int*)&var);
2565 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2568 }
while (curr != prev);
2569 return (
unsigned int)curr;
2573 #ifdef AO_HAVE_int_fetch_compare_and_swap
2576 unsigned int& var,
unsigned int& exp,
unsigned int des) {
2578 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2581 unsigned int old = AO_int_fetch_compare_and_swap(
2582 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2583 const bool ret = ((
unsigned int)exp == old);
2587 exp = (
unsigned int)old;
2592 #ifdef AO_HAVE_int_fetch_and_add_full
2594 static inline unsigned int fetch_add_seq_cst(
unsigned int& var,
unsigned int val) {
2596 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2598 return (
unsigned int)(
2599 AO_int_fetch_and_add_full((
unsigned int*)&var, (
unsigned int)val));
2603 #ifdef AO_HAVE_int_fetch_and_add_full
2605 static inline unsigned int fetch_sub_seq_cst(
unsigned int& var,
unsigned int val) {
2607 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2609 return (
unsigned int)(
2610 AO_int_fetch_and_add_full((
unsigned int*)&var, (
unsigned int)-val));
2614 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
2616 static inline unsigned int fetch_and_seq_cst(
unsigned int& var,
unsigned int val) {
2618 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2621 unsigned int curr = AO_int_load((
unsigned int*)&var);
2625 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2626 prev & (
unsigned int)val);
2628 }
while (curr != prev);
2629 return (
unsigned int)curr;
2633 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
2635 static inline unsigned int fetch_or_seq_cst(
unsigned int& var,
unsigned int val) {
2637 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2640 unsigned int curr = AO_int_load((
unsigned int*)&var);
2644 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2645 prev | (
unsigned int)val);
2647 }
while (curr != prev);
2648 return (
unsigned int)curr;
2652 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
2654 static inline unsigned int fetch_xor_seq_cst(
unsigned int& var,
unsigned int val) {
2656 int f :
sizeof(
unsigned int) ==
sizeof(
unsigned int) ? 1 : -1;
2659 unsigned int curr = AO_int_load((
unsigned int*)&var);
2663 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2664 prev ^ (
unsigned int)val);
2666 }
while (curr != prev);
2667 return (
unsigned int)curr;
2673 #ifdef AO_HAVE_int_load
2677 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2679 return (
int)AO_int_load((
unsigned int const*)&var);
2683 #ifdef AO_HAVE_int_store
2687 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2689 AO_int_store((
unsigned int*)&var, (
unsigned int)val);
2693 #ifdef AO_HAVE_int_fetch_compare_and_swap
2697 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2699 unsigned int curr = AO_int_load((
unsigned int*)&var);
2703 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2705 }
while (curr != prev);
2710 #ifdef AO_HAVE_int_fetch_compare_and_swap
2713 int& var,
int& exp,
int des) {
2715 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2717 unsigned int old = AO_int_fetch_compare_and_swap(
2718 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2719 const bool ret = ((
unsigned int)exp == old);
2725 #ifdef AO_HAVE_int_fetch_and_add
2729 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2732 AO_int_fetch_and_add((
unsigned int*)&var, (
unsigned int)val));
2736 #ifdef AO_HAVE_int_fetch_and_add
2740 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2743 AO_int_fetch_and_add((
unsigned int*)&var, (
unsigned int)-val));
2747 #ifdef AO_HAVE_int_fetch_compare_and_swap
2751 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2753 unsigned int curr = AO_int_load((
unsigned int*)&var);
2757 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2758 prev & (
unsigned int)val);
2759 }
while (curr != prev);
2764 #ifdef AO_HAVE_int_fetch_compare_and_swap
2768 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2770 unsigned int curr = AO_int_load((
unsigned int*)&var);
2774 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2775 prev | (
unsigned int)val);
2776 }
while (curr != prev);
2781 #ifdef AO_HAVE_int_fetch_compare_and_swap
2785 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2787 unsigned int curr = AO_int_load((
unsigned int*)&var);
2791 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
2792 prev ^ (
unsigned int)val);
2793 }
while (curr != prev);
2798 #ifdef AO_HAVE_int_load_acquire
2802 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2804 return (
int)AO_int_load_acquire((
unsigned int const*)&var);
2808 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2812 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2814 unsigned int curr = AO_int_load((
unsigned int*)&var);
2818 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2820 }
while (curr != prev);
2825 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2828 int& var,
int& exp,
int des) {
2830 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2832 unsigned int old = AO_int_fetch_compare_and_swap_acquire(
2833 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2834 const bool ret = ((
unsigned int)exp == old);
2840 #ifdef AO_HAVE_int_fetch_and_add_acquire
2844 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2847 AO_int_fetch_and_add_acquire((
unsigned int*)&var, (
unsigned int)val));
2851 #ifdef AO_HAVE_int_fetch_and_add_acquire
2855 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2858 AO_int_fetch_and_add_acquire((
unsigned int*)&var, (
unsigned int)-val));
2862 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2866 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2868 unsigned int curr = AO_int_load((
unsigned int*)&var);
2872 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2873 prev & (
unsigned int)val);
2874 }
while (curr != prev);
2879 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2883 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2885 unsigned int curr = AO_int_load((
unsigned int*)&var);
2889 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2890 prev | (
unsigned int)val);
2891 }
while (curr != prev);
2896 #ifdef AO_HAVE_int_fetch_compare_and_swap_acquire
2900 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2902 unsigned int curr = AO_int_load((
unsigned int*)&var);
2906 curr = AO_int_fetch_compare_and_swap_acquire((
unsigned int*)&var, prev,
2907 prev ^ (
unsigned int)val);
2908 }
while (curr != prev);
2913 #ifdef AO_HAVE_int_store_release
2917 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2919 AO_int_store_release((
unsigned int*)&var, (
unsigned int)val);
2923 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2927 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2929 unsigned int curr = AO_int_load((
unsigned int*)&var);
2933 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2935 }
while (curr != prev);
2940 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2943 int& var,
int& exp,
int des) {
2945 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2947 unsigned int old = AO_int_fetch_compare_and_swap_release(
2948 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
2949 const bool ret = ((
unsigned int)exp == old);
2955 #ifdef AO_HAVE_int_fetch_and_add_release
2959 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2962 AO_int_fetch_and_add_release((
unsigned int*)&var, (
unsigned int)val));
2966 #ifdef AO_HAVE_int_fetch_and_add_release
2970 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2973 AO_int_fetch_and_add_release((
unsigned int*)&var, (
unsigned int)-val));
2977 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2981 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
2983 unsigned int curr = AO_int_load((
unsigned int*)&var);
2987 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
2988 prev & (
unsigned int)val);
2989 }
while (curr != prev);
2994 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
2998 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3000 unsigned int curr = AO_int_load((
unsigned int*)&var);
3004 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
3005 prev | (
unsigned int)val);
3006 }
while (curr != prev);
3011 #ifdef AO_HAVE_int_fetch_compare_and_swap_release
3015 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3017 unsigned int curr = AO_int_load((
unsigned int*)&var);
3021 curr = AO_int_fetch_compare_and_swap_release((
unsigned int*)&var, prev,
3022 prev ^ (
unsigned int)val);
3023 }
while (curr != prev);
3028 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
3032 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3034 unsigned int curr = AO_int_load((
unsigned int*)&var);
3038 curr = AO_int_fetch_compare_and_swap_full((
unsigned int*)&var, prev,
3040 }
while (curr != prev);
3045 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
3048 int& var,
int& exp,
int des) {
3050 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3052 unsigned int old = AO_int_fetch_compare_and_swap_full(
3053 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
3054 const bool ret = ((
unsigned int)exp == old);
3060 #ifdef AO_HAVE_int_load_full
3064 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3066 return (
int)AO_int_load_full((
unsigned int const*)&var);
3070 #ifdef AO_HAVE_int_store_full
3074 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3076 AO_int_store_full((
unsigned int*)&var, (
unsigned int)val);
3080 #ifdef AO_HAVE_int_fetch_compare_and_swap
3084 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3087 unsigned int curr = AO_int_load((
unsigned int*)&var);
3091 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
3094 }
while (curr != prev);
3099 #ifdef AO_HAVE_int_fetch_compare_and_swap
3102 int& var,
int& exp,
int des) {
3104 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3107 unsigned int old = AO_int_fetch_compare_and_swap(
3108 (
unsigned int*)&var, (
unsigned int)exp, (
unsigned int)des);
3109 const bool ret = ((
unsigned int)exp == old);
3118 #ifdef AO_HAVE_int_fetch_and_add_full
3122 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3125 AO_int_fetch_and_add_full((
unsigned int*)&var, (
unsigned int)val));
3129 #ifdef AO_HAVE_int_fetch_and_add_full
3133 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3136 AO_int_fetch_and_add_full((
unsigned int*)&var, (
unsigned int)-val));
3140 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
3144 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3147 unsigned int curr = AO_int_load((
unsigned int*)&var);
3151 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
3152 prev & (
unsigned int)val);
3154 }
while (curr != prev);
3159 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
3163 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3166 unsigned int curr = AO_int_load((
unsigned int*)&var);
3170 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
3171 prev | (
unsigned int)val);
3173 }
while (curr != prev);
3178 #ifdef AO_HAVE_int_fetch_compare_and_swap_full
3182 int f :
sizeof(int) ==
sizeof(
unsigned int) ? 1 : -1;
3185 unsigned int curr = AO_int_load((
unsigned int*)&var);
3189 curr = AO_int_fetch_compare_and_swap((
unsigned int*)&var, prev,
3190 prev ^ (
unsigned int)val);
3192 }
while (curr != prev);
3205 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3207 return (
size_t)AO_load((AO_t
const*)&var);
3211 #ifdef AO_HAVE_store
3215 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3217 AO_store((AO_t*)&var, (AO_t)val);
3221 #ifdef AO_HAVE_fetch_compare_and_swap
3225 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3227 AO_t curr = AO_load((AO_t*)&var);
3231 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3233 }
while (curr != prev);
3234 return (
size_t)curr;
3238 #ifdef AO_HAVE_fetch_compare_and_swap
3241 size_t& var,
size_t& exp,
size_t des) {
3243 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3245 AO_t old = AO_fetch_compare_and_swap(
3246 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3247 const bool ret = ((AO_t)exp == old);
3253 #ifdef AO_HAVE_fetch_and_add
3257 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3260 AO_fetch_and_add((AO_t*)&var, (AO_t)val));
3264 #ifdef AO_HAVE_fetch_and_add
3268 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3271 AO_fetch_and_add((AO_t*)&var, (AO_t)-val));
3275 #ifdef AO_HAVE_fetch_compare_and_swap
3279 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3281 AO_t curr = AO_load((AO_t*)&var);
3285 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3287 }
while (curr != prev);
3288 return (
size_t)curr;
3292 #ifdef AO_HAVE_fetch_compare_and_swap
3296 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3298 AO_t curr = AO_load((AO_t*)&var);
3302 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3304 }
while (curr != prev);
3305 return (
size_t)curr;
3309 #ifdef AO_HAVE_fetch_compare_and_swap
3313 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3315 AO_t curr = AO_load((AO_t*)&var);
3319 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3321 }
while (curr != prev);
3322 return (
size_t)curr;
3326 #ifdef AO_HAVE_load_acquire
3330 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3332 return (
size_t)AO_load_acquire((AO_t
const*)&var);
3336 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3340 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3342 AO_t curr = AO_load((AO_t*)&var);
3346 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3348 }
while (curr != prev);
3349 return (
size_t)curr;
3353 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3356 size_t& var,
size_t& exp,
size_t des) {
3358 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3360 AO_t old = AO_fetch_compare_and_swap_acquire(
3361 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3362 const bool ret = ((AO_t)exp == old);
3368 #ifdef AO_HAVE_fetch_and_add_acquire
3372 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3375 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)val));
3379 #ifdef AO_HAVE_fetch_and_add_acquire
3383 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3386 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)-val));
3390 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3394 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3396 AO_t curr = AO_load((AO_t*)&var);
3400 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3402 }
while (curr != prev);
3403 return (
size_t)curr;
3407 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3411 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3413 AO_t curr = AO_load((AO_t*)&var);
3417 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3419 }
while (curr != prev);
3420 return (
size_t)curr;
3424 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3428 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3430 AO_t curr = AO_load((AO_t*)&var);
3434 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3436 }
while (curr != prev);
3437 return (
size_t)curr;
3441 #ifdef AO_HAVE_store_release
3445 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3447 AO_store_release((AO_t*)&var, (AO_t)val);
3451 #ifdef AO_HAVE_fetch_compare_and_swap_release
3455 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3457 AO_t curr = AO_load((AO_t*)&var);
3461 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
3463 }
while (curr != prev);
3464 return (
size_t)curr;
3468 #ifdef AO_HAVE_fetch_compare_and_swap_release
3471 size_t& var,
size_t& exp,
size_t des) {
3473 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3475 AO_t old = AO_fetch_compare_and_swap_release(
3476 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3477 const bool ret = ((AO_t)exp == old);
3483 #ifdef AO_HAVE_fetch_and_add_release
3487 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3490 AO_fetch_and_add_release((AO_t*)&var, (AO_t)val));
3494 #ifdef AO_HAVE_fetch_and_add_release
3498 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3501 AO_fetch_and_add_release((AO_t*)&var, (AO_t)-val));
3505 #ifdef AO_HAVE_fetch_compare_and_swap_release
3509 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3511 AO_t curr = AO_load((AO_t*)&var);
3515 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
3517 }
while (curr != prev);
3518 return (
size_t)curr;
3522 #ifdef AO_HAVE_fetch_compare_and_swap_release
3526 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3528 AO_t curr = AO_load((AO_t*)&var);
3532 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
3534 }
while (curr != prev);
3535 return (
size_t)curr;
3539 #ifdef AO_HAVE_fetch_compare_and_swap_release
3543 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3545 AO_t curr = AO_load((AO_t*)&var);
3549 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
3551 }
while (curr != prev);
3552 return (
size_t)curr;
3556 #ifdef AO_HAVE_fetch_compare_and_swap_full
3560 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3562 AO_t curr = AO_load((AO_t*)&var);
3566 curr = AO_fetch_compare_and_swap_full((AO_t*)&var, prev,
3568 }
while (curr != prev);
3569 return (
size_t)curr;
3573 #ifdef AO_HAVE_fetch_compare_and_swap_full
3576 size_t& var,
size_t& exp,
size_t des) {
3578 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3580 AO_t old = AO_fetch_compare_and_swap_full(
3581 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3582 const bool ret = ((AO_t)exp == old);
3588 #ifdef AO_HAVE_load_full
3592 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3594 return (
size_t)AO_load_full((AO_t
const*)&var);
3598 #ifdef AO_HAVE_store_full
3602 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3604 AO_store_full((AO_t*)&var, (AO_t)val);
3608 #ifdef AO_HAVE_fetch_compare_and_swap
3612 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3615 AO_t curr = AO_load((AO_t*)&var);
3619 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3622 }
while (curr != prev);
3623 return (
size_t)curr;
3627 #ifdef AO_HAVE_fetch_compare_and_swap
3630 size_t& var,
size_t& exp,
size_t des) {
3632 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3635 AO_t old = AO_fetch_compare_and_swap(
3636 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3637 const bool ret = ((AO_t)exp == old);
3646 #ifdef AO_HAVE_fetch_and_add_full
3650 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3653 AO_fetch_and_add_full((AO_t*)&var, (AO_t)val));
3657 #ifdef AO_HAVE_fetch_and_add_full
3661 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3664 AO_fetch_and_add_full((AO_t*)&var, (AO_t)-val));
3668 #ifdef AO_HAVE_fetch_compare_and_swap_full
3672 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3675 AO_t curr = AO_load((AO_t*)&var);
3679 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3682 }
while (curr != prev);
3683 return (
size_t)curr;
3687 #ifdef AO_HAVE_fetch_compare_and_swap_full
3691 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3694 AO_t curr = AO_load((AO_t*)&var);
3698 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3701 }
while (curr != prev);
3702 return (
size_t)curr;
3706 #ifdef AO_HAVE_fetch_compare_and_swap_full
3710 int f :
sizeof(size_t) ==
sizeof(AO_t) ? 1 : -1;
3713 AO_t curr = AO_load((AO_t*)&var);
3717 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3720 }
while (curr != prev);
3721 return (
size_t)curr;
3729 static inline ssize_t
load_relaxed(ssize_t
const& var) {
3731 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3733 return (ssize_t)AO_load((AO_t
const*)&var);
3737 #ifdef AO_HAVE_store
3739 static inline void store_relaxed(ssize_t& var, ssize_t val) {
3741 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3743 AO_store((AO_t*)&var, (AO_t)val);
3747 #ifdef AO_HAVE_fetch_compare_and_swap
3751 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3753 AO_t curr = AO_load((AO_t*)&var);
3757 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3759 }
while (curr != prev);
3760 return (ssize_t)curr;
3764 #ifdef AO_HAVE_fetch_compare_and_swap
3767 ssize_t& var, ssize_t& exp, ssize_t des) {
3769 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3771 AO_t old = AO_fetch_compare_and_swap(
3772 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3773 const bool ret = ((AO_t)exp == old);
3779 #ifdef AO_HAVE_fetch_and_add
3783 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3786 AO_fetch_and_add((AO_t*)&var, (AO_t)val));
3790 #ifdef AO_HAVE_fetch_and_add
3794 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3797 AO_fetch_and_add((AO_t*)&var, (AO_t)-val));
3801 #ifdef AO_HAVE_fetch_compare_and_swap
3805 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3807 AO_t curr = AO_load((AO_t*)&var);
3811 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3813 }
while (curr != prev);
3814 return (ssize_t)curr;
3818 #ifdef AO_HAVE_fetch_compare_and_swap
3822 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3824 AO_t curr = AO_load((AO_t*)&var);
3828 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3830 }
while (curr != prev);
3831 return (ssize_t)curr;
3835 #ifdef AO_HAVE_fetch_compare_and_swap
3839 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3841 AO_t curr = AO_load((AO_t*)&var);
3845 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
3847 }
while (curr != prev);
3848 return (ssize_t)curr;
3852 #ifdef AO_HAVE_load_acquire
3854 static inline ssize_t
load_acquire(ssize_t
const& var) {
3856 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3858 return (ssize_t)AO_load_acquire((AO_t
const*)&var);
3862 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3866 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3868 AO_t curr = AO_load((AO_t*)&var);
3872 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3874 }
while (curr != prev);
3875 return (ssize_t)curr;
3879 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3882 ssize_t& var, ssize_t& exp, ssize_t des) {
3884 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3886 AO_t old = AO_fetch_compare_and_swap_acquire(
3887 (AO_t*)&var, (AO_t)exp, (AO_t)des);
3888 const bool ret = ((AO_t)exp == old);
3894 #ifdef AO_HAVE_fetch_and_add_acquire
3898 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3901 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)val));
3905 #ifdef AO_HAVE_fetch_and_add_acquire
3909 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3912 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)-val));
3916 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3920 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3922 AO_t curr = AO_load((AO_t*)&var);
3926 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3928 }
while (curr != prev);
3929 return (ssize_t)curr;
3933 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3937 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3939 AO_t curr = AO_load((AO_t*)&var);
3943 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3945 }
while (curr != prev);
3946 return (ssize_t)curr;
3950 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
3954 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3956 AO_t curr = AO_load((AO_t*)&var);
3960 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
3962 }
while (curr != prev);
3963 return (ssize_t)curr;
3967 #ifdef AO_HAVE_store_release
3969 static inline void store_release(ssize_t& var, ssize_t val) {
3971 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3973 AO_store_release((AO_t*)&var, (AO_t)val);
3977 #ifdef AO_HAVE_fetch_compare_and_swap_release
3981 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
3983 AO_t curr = AO_load((AO_t*)&var);
3987 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
3989 }
while (curr != prev);
3990 return (ssize_t)curr;
3994 #ifdef AO_HAVE_fetch_compare_and_swap_release
3997 ssize_t& var, ssize_t& exp, ssize_t des) {
3999 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4001 AO_t old = AO_fetch_compare_and_swap_release(
4002 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4003 const bool ret = ((AO_t)exp == old);
4009 #ifdef AO_HAVE_fetch_and_add_release
4013 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4016 AO_fetch_and_add_release((AO_t*)&var, (AO_t)val));
4020 #ifdef AO_HAVE_fetch_and_add_release
4024 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4027 AO_fetch_and_add_release((AO_t*)&var, (AO_t)-val));
4031 #ifdef AO_HAVE_fetch_compare_and_swap_release
4035 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4037 AO_t curr = AO_load((AO_t*)&var);
4041 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4043 }
while (curr != prev);
4044 return (ssize_t)curr;
4048 #ifdef AO_HAVE_fetch_compare_and_swap_release
4052 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4054 AO_t curr = AO_load((AO_t*)&var);
4058 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4060 }
while (curr != prev);
4061 return (ssize_t)curr;
4065 #ifdef AO_HAVE_fetch_compare_and_swap_release
4069 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4071 AO_t curr = AO_load((AO_t*)&var);
4075 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4077 }
while (curr != prev);
4078 return (ssize_t)curr;
4082 #ifdef AO_HAVE_fetch_compare_and_swap_full
4086 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4088 AO_t curr = AO_load((AO_t*)&var);
4092 curr = AO_fetch_compare_and_swap_full((AO_t*)&var, prev,
4094 }
while (curr != prev);
4095 return (ssize_t)curr;
4099 #ifdef AO_HAVE_fetch_compare_and_swap_full
4102 ssize_t& var, ssize_t& exp, ssize_t des) {
4104 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4106 AO_t old = AO_fetch_compare_and_swap_full(
4107 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4108 const bool ret = ((AO_t)exp == old);
4114 #ifdef AO_HAVE_load_full
4116 static inline ssize_t
load_seq_cst(ssize_t
const& var) {
4118 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4120 return (ssize_t)AO_load_full((AO_t
const*)&var);
4124 #ifdef AO_HAVE_store_full
4126 static inline void store_seq_cst(ssize_t& var, ssize_t val) {
4128 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4130 AO_store_full((AO_t*)&var, (AO_t)val);
4134 #ifdef AO_HAVE_fetch_compare_and_swap
4138 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4141 AO_t curr = AO_load((AO_t*)&var);
4145 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4148 }
while (curr != prev);
4149 return (ssize_t)curr;
4153 #ifdef AO_HAVE_fetch_compare_and_swap
4156 ssize_t& var, ssize_t& exp, ssize_t des) {
4158 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4161 AO_t old = AO_fetch_compare_and_swap(
4162 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4163 const bool ret = ((AO_t)exp == old);
4172 #ifdef AO_HAVE_fetch_and_add_full
4176 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4179 AO_fetch_and_add_full((AO_t*)&var, (AO_t)val));
4183 #ifdef AO_HAVE_fetch_and_add_full
4187 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4190 AO_fetch_and_add_full((AO_t*)&var, (AO_t)-val));
4194 #ifdef AO_HAVE_fetch_compare_and_swap_full
4198 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4201 AO_t curr = AO_load((AO_t*)&var);
4205 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4208 }
while (curr != prev);
4209 return (ssize_t)curr;
4213 #ifdef AO_HAVE_fetch_compare_and_swap_full
4217 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4220 AO_t curr = AO_load((AO_t*)&var);
4224 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4227 }
while (curr != prev);
4228 return (ssize_t)curr;
4232 #ifdef AO_HAVE_fetch_compare_and_swap_full
4236 int f :
sizeof(ssize_t) ==
sizeof(AO_t) ? 1 : -1;
4239 AO_t curr = AO_load((AO_t*)&var);
4243 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4246 }
while (curr != prev);
4247 return (ssize_t)curr;
4255 template <
class T>
static inline T*
load_relaxed(T*
const& var) {
4257 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4259 return (T*)AO_load((AO_t
const*)&var);
4263 #ifdef AO_HAVE_store
4265 template <
class T>
static inline void store_relaxed(T*& var, T* val) {
4267 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4269 AO_store((AO_t*)&var, (AO_t)val);
4273 #ifdef AO_HAVE_fetch_compare_and_swap
4277 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4279 AO_t curr = AO_load((AO_t*)&var);
4283 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4285 }
while (curr != prev);
4290 #ifdef AO_HAVE_fetch_compare_and_swap
4293 T*& var, T*& exp, T* des) {
4295 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4297 AO_t old = AO_fetch_compare_and_swap(
4298 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4299 const bool ret = ((AO_t)exp == old);
4305 #ifdef AO_HAVE_fetch_and_add
4309 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4312 AO_fetch_and_add((AO_t*)&var, (AO_t)val));
4316 #ifdef AO_HAVE_fetch_and_add
4320 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4323 AO_fetch_and_add((AO_t*)&var, (AO_t)-val));
4327 #ifdef AO_HAVE_fetch_compare_and_swap
4331 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4333 AO_t curr = AO_load((AO_t*)&var);
4337 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4339 }
while (curr != prev);
4344 #ifdef AO_HAVE_fetch_compare_and_swap
4346 template <
class T>
static inline T*
fetch_or_relaxed(T*& var, ptrdiff_t val) {
4348 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4350 AO_t curr = AO_load((AO_t*)&var);
4354 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4356 }
while (curr != prev);
4361 #ifdef AO_HAVE_fetch_compare_and_swap
4365 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4367 AO_t curr = AO_load((AO_t*)&var);
4371 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4373 }
while (curr != prev);
4378 #ifdef AO_HAVE_load_acquire
4380 template <
class T>
static inline T*
load_acquire(T*
const& var) {
4382 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4384 return (T*)AO_load_acquire((AO_t
const*)&var);
4388 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
4392 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4394 AO_t curr = AO_load((AO_t*)&var);
4398 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
4400 }
while (curr != prev);
4405 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
4408 T*& var, T*& exp, T* des) {
4410 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4412 AO_t old = AO_fetch_compare_and_swap_acquire(
4413 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4414 const bool ret = ((AO_t)exp == old);
4420 #ifdef AO_HAVE_fetch_and_add_acquire
4424 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4427 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)val));
4431 #ifdef AO_HAVE_fetch_and_add_acquire
4435 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4438 AO_fetch_and_add_acquire((AO_t*)&var, (AO_t)-val));
4442 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
4446 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4448 AO_t curr = AO_load((AO_t*)&var);
4452 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
4454 }
while (curr != prev);
4459 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
4461 template <
class T>
static inline T*
fetch_or_acquire(T*& var, ptrdiff_t val) {
4463 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4465 AO_t curr = AO_load((AO_t*)&var);
4469 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
4471 }
while (curr != prev);
4476 #ifdef AO_HAVE_fetch_compare_and_swap_acquire
4480 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4482 AO_t curr = AO_load((AO_t*)&var);
4486 curr = AO_fetch_compare_and_swap_acquire((AO_t*)&var, prev,
4488 }
while (curr != prev);
4493 #ifdef AO_HAVE_store_release
4495 template <
class T>
static inline void store_release(T*& var, T* val) {
4497 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4499 AO_store_release((AO_t*)&var, (AO_t)val);
4503 #ifdef AO_HAVE_fetch_compare_and_swap_release
4507 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4509 AO_t curr = AO_load((AO_t*)&var);
4513 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4515 }
while (curr != prev);
4520 #ifdef AO_HAVE_fetch_compare_and_swap_release
4523 T*& var, T*& exp, T* des) {
4525 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4527 AO_t old = AO_fetch_compare_and_swap_release(
4528 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4529 const bool ret = ((AO_t)exp == old);
4535 #ifdef AO_HAVE_fetch_and_add_release
4539 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4542 AO_fetch_and_add_release((AO_t*)&var, (AO_t)val));
4546 #ifdef AO_HAVE_fetch_and_add_release
4550 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4553 AO_fetch_and_add_release((AO_t*)&var, (AO_t)-val));
4557 #ifdef AO_HAVE_fetch_compare_and_swap_release
4561 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4563 AO_t curr = AO_load((AO_t*)&var);
4567 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4569 }
while (curr != prev);
4574 #ifdef AO_HAVE_fetch_compare_and_swap_release
4576 template <
class T>
static inline T*
fetch_or_release(T*& var, ptrdiff_t val) {
4578 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4580 AO_t curr = AO_load((AO_t*)&var);
4584 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4586 }
while (curr != prev);
4591 #ifdef AO_HAVE_fetch_compare_and_swap_release
4595 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4597 AO_t curr = AO_load((AO_t*)&var);
4601 curr = AO_fetch_compare_and_swap_release((AO_t*)&var, prev,
4603 }
while (curr != prev);
4608 #ifdef AO_HAVE_fetch_compare_and_swap_full
4612 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4614 AO_t curr = AO_load((AO_t*)&var);
4618 curr = AO_fetch_compare_and_swap_full((AO_t*)&var, prev,
4620 }
while (curr != prev);
4625 #ifdef AO_HAVE_fetch_compare_and_swap_full
4628 T*& var, T*& exp, T* des) {
4630 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4632 AO_t old = AO_fetch_compare_and_swap_full(
4633 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4634 const bool ret = ((AO_t)exp == old);
4640 #ifdef AO_HAVE_load_full
4642 template <
class T>
static inline T*
load_seq_cst(T*
const& var) {
4644 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4646 return (T*)AO_load_full((AO_t
const*)&var);
4650 #ifdef AO_HAVE_store_full
4652 template <
class T>
static inline void store_seq_cst(T*& var, T* val) {
4654 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4656 AO_store_full((AO_t*)&var, (AO_t)val);
4660 #ifdef AO_HAVE_fetch_compare_and_swap
4664 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4667 AO_t curr = AO_load((AO_t*)&var);
4671 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4674 }
while (curr != prev);
4679 #ifdef AO_HAVE_fetch_compare_and_swap
4682 T*& var, T*& exp, T* des) {
4684 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4687 AO_t old = AO_fetch_compare_and_swap(
4688 (AO_t*)&var, (AO_t)exp, (AO_t)des);
4689 const bool ret = ((AO_t)exp == old);
4698 #ifdef AO_HAVE_fetch_and_add_full
4702 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4705 AO_fetch_and_add_full((AO_t*)&var, (AO_t)val));
4709 #ifdef AO_HAVE_fetch_and_add_full
4713 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4716 AO_fetch_and_add_full((AO_t*)&var, (AO_t)-val));
4720 #ifdef AO_HAVE_fetch_compare_and_swap_full
4724 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4727 AO_t curr = AO_load((AO_t*)&var);
4731 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4734 }
while (curr != prev);
4739 #ifdef AO_HAVE_fetch_compare_and_swap_full
4741 template <
class T>
static inline T*
fetch_or_seq_cst(T*& var, ptrdiff_t val) {
4743 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4746 AO_t curr = AO_load((AO_t*)&var);
4750 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4753 }
while (curr != prev);
4758 #ifdef AO_HAVE_fetch_compare_and_swap_full
4762 int f :
sizeof(T*) ==
sizeof(AO_t) ? 1 : -1;
4765 AO_t curr = AO_load((AO_t*)&var);
4769 curr = AO_fetch_compare_and_swap((AO_t*)&var, prev,
4772 }
while (curr != prev);
static T1 fetch_and_release(T1 &var, T2 val)
Atomic fetch-and (release barrier).
static T1 fetch_or_acquire(T1 &var, T2 val)
Atomic fetch-or (acquire barrier).
static T1 exchange_release(T1 &var, T2 val)
Atomic exchange (release barrier).
static void store_relaxed(T1 &var, T2 val)
Atomic store (no barrier).
static T1 fetch_add_release(T1 &var, T2 val)
Atomic add-and-fetch (release barrier).
static void fence_seq_cst()
Full memory barrier.
static T1 fetch_or_release(T1 &var, T2 val)
Atomic fetch-or (release barrier).
static void fence_acquire()
Acquire memory barrier.
static T1 exchange_seq_cst(T1 &var, T2 val)
Atomic exchange (full barrier).
static T1 fetch_or_relaxed(T1 &var, T2 val)
Atomic fetch-or (no barrier).
static T1 exchange_relaxed(T1 &var, T2 val)
Atomic exchange (no barrier).
static T1 exchange_acquire(T1 &var, T2 val)
Atomic exchange (acquire barrier).
static T1 fetch_sub_seq_cst(T1 &var, T2 val)
Atomic sub-and-fetch (full barrier).
static bool compare_exchange_acq_rel(T1 &var, T1 &exp, T2 des)
Atomic compare-and-swap (acquire-release barrier).
static void store_seq_cst(T1 &var, T2 val)
Atomic store (full barrier).
static T load_relaxed(const T &var)
Atomic load (no barrier).
static T1 fetch_or_seq_cst(T1 &var, T2 val)
Atomic fetch-or (full barrier).
static bool compare_exchange_seq_cst(T1 &var, T1 &exp, T2 des)
Atomic compare-and-swap (full barrier).
static T load_acquire(const T &var)
Atomic load (acquire barrier).
static bool compare_exchange_acquire(T1 &var, T1 &exp, T2 des)
Atomic compare-and-swap (acquire barrier).
static void store_release(T1 &var, T2 val)
Atomic store (release barrier).
static void fence_release()
Release memory barrier.
static T1 fetch_xor_relaxed(T1 &var, T2 val)
Atomic fetch-xor (no barrier).
static T1 fetch_and_seq_cst(T1 &var, T2 val)
Atomic fetch-and (full barrier).
static T1 fetch_add_seq_cst(T1 &var, T2 val)
Atomic add-and-fetch (full barrier).
static T1 exchange_acq_rel(T1 &var, T2 val)
Atomic exchange (acquire-release barrier).
static T1 fetch_and_acquire(T1 &var, T2 val)
Atomic fetch-and (acquire barrier).
static T1 fetch_xor_acquire(T1 &var, T2 val)
Atomic fetch-xor (acquire barrier).
static T1 fetch_add_acquire(T1 &var, T2 val)
Atomic add-and-fetch (acquire barrier).
static bool compare_exchange_relaxed(T1 &var, T1 &exp, T2 des)
Atomic compare-and-swap (no barrier).
static T1 fetch_sub_release(T1 &var, T2 val)
Atomic sub-and-fetch (release barrier).
static T1 fetch_sub_relaxed(T1 &var, T2 val)
Atomic fetch-sub (no barrier).
static T1 fetch_and_relaxed(T1 &var, T2 val)
Atomic fetch-and (no barrier).
static T1 fetch_sub_acquire(T1 &var, T2 val)
Atomic sub-and-fetch (acquire barrier).
static T1 fetch_xor_release(T1 &var, T2 val)
Atomic fetch-xor (release barrier).
static T1 fetch_xor_seq_cst(T1 &var, T2 val)
Atomic fetch-xor (full barrier).
static bool compare_exchange_release(T1 &var, T1 &exp, T2 des)
Atomic compare-and-swap (release barrier).
static T load_seq_cst(const T &var)
Atomic load (full barrier).
static T1 fetch_add_relaxed(T1 &var, T2 val)
Atomic fetch-add (no barrier).
Commonly used types and functions.