Created
December 25, 2011 19:53
-
-
Save brycelelbach/1519668 to your computer and use it in GitHub Desktop.
GCC builtin atomics availability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
int main() | |
{ | |
__sync_synchronize(); | |
{ | |
typedef uint8_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_1(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_1(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_1(x, 1); | |
type r11 = __sync_fetch_and_sub_1(x, 1); | |
type r12 = __sync_fetch_and_or_1(x, 1); | |
type r13 = __sync_fetch_and_and_1(x, 1); | |
type r14 = __sync_fetch_and_xor_1(x, 1); | |
type r15 = __sync_fetch_and_nand_1(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_1(x, 1); | |
type r23 = __sync_sub_and_fetch_1(x, 1); | |
type r24 = __sync_or_and_fetch_1(x, 1); | |
type r25 = __sync_and_and_fetch_1(x, 1); | |
type r26 = __sync_xor_and_fetch_1(x, 1); | |
type r27 = __sync_nand_and_fetch_1(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_1(x, 1); | |
__sync_lock_release_1(x); | |
delete x; | |
} | |
{ | |
typedef int8_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_1(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_1(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_1(x, 1); | |
type r11 = __sync_fetch_and_sub_1(x, 1); | |
type r12 = __sync_fetch_and_or_1(x, 1); | |
type r13 = __sync_fetch_and_and_1(x, 1); | |
type r14 = __sync_fetch_and_xor_1(x, 1); | |
type r15 = __sync_fetch_and_nand_1(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_1(x, 1); | |
type r23 = __sync_sub_and_fetch_1(x, 1); | |
type r24 = __sync_or_and_fetch_1(x, 1); | |
type r25 = __sync_and_and_fetch_1(x, 1); | |
type r26 = __sync_xor_and_fetch_1(x, 1); | |
type r27 = __sync_nand_and_fetch_1(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_1(x, 1); | |
__sync_lock_release_1(x); | |
delete x; | |
} | |
{ | |
typedef uint16_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_2(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_2(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_2(x, 1); | |
type r11 = __sync_fetch_and_sub_2(x, 1); | |
type r12 = __sync_fetch_and_or_2(x, 1); | |
type r13 = __sync_fetch_and_and_2(x, 1); | |
type r14 = __sync_fetch_and_xor_2(x, 1); | |
type r15 = __sync_fetch_and_nand_2(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_2(x, 1); | |
type r23 = __sync_sub_and_fetch_2(x, 1); | |
type r24 = __sync_or_and_fetch_2(x, 1); | |
type r25 = __sync_and_and_fetch_2(x, 1); | |
type r26 = __sync_xor_and_fetch_2(x, 1); | |
type r27 = __sync_nand_and_fetch_2(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_2(x, 1); | |
__sync_lock_release_2(x); | |
delete x; | |
} | |
{ | |
typedef int16_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_2(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_2(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_2(x, 1); | |
type r11 = __sync_fetch_and_sub_2(x, 1); | |
type r12 = __sync_fetch_and_or_2(x, 1); | |
type r13 = __sync_fetch_and_and_2(x, 1); | |
type r14 = __sync_fetch_and_xor_2(x, 1); | |
type r15 = __sync_fetch_and_nand_2(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_2(x, 1); | |
type r23 = __sync_sub_and_fetch_2(x, 1); | |
type r24 = __sync_or_and_fetch_2(x, 1); | |
type r25 = __sync_and_and_fetch_2(x, 1); | |
type r26 = __sync_xor_and_fetch_2(x, 1); | |
type r27 = __sync_nand_and_fetch_2(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_2(x, 1); | |
__sync_lock_release_2(x); | |
delete x; | |
} | |
{ | |
typedef uint32_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_4(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_4(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_4(x, 1); | |
type r11 = __sync_fetch_and_sub_4(x, 1); | |
type r12 = __sync_fetch_and_or_4(x, 1); | |
type r13 = __sync_fetch_and_and_4(x, 1); | |
type r14 = __sync_fetch_and_xor_4(x, 1); | |
type r15 = __sync_fetch_and_nand_4(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_4(x, 1); | |
type r23 = __sync_sub_and_fetch_4(x, 1); | |
type r24 = __sync_or_and_fetch_4(x, 1); | |
type r25 = __sync_and_and_fetch_4(x, 1); | |
type r26 = __sync_xor_and_fetch_4(x, 1); | |
type r27 = __sync_nand_and_fetch_4(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_4(x, 1); | |
__sync_lock_release_4(x); | |
delete x; | |
} | |
{ | |
typedef int32_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_4(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_4(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_4(x, 1); | |
type r11 = __sync_fetch_and_sub_4(x, 1); | |
type r12 = __sync_fetch_and_or_4(x, 1); | |
type r13 = __sync_fetch_and_and_4(x, 1); | |
type r14 = __sync_fetch_and_xor_4(x, 1); | |
type r15 = __sync_fetch_and_nand_4(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_4(x, 1); | |
type r23 = __sync_sub_and_fetch_4(x, 1); | |
type r24 = __sync_or_and_fetch_4(x, 1); | |
type r25 = __sync_and_and_fetch_4(x, 1); | |
type r26 = __sync_xor_and_fetch_4(x, 1); | |
type r27 = __sync_nand_and_fetch_4(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_4(x, 1); | |
__sync_lock_release_4(x); | |
delete x; | |
} | |
{ | |
typedef uint64_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_8(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_8(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_8(x, 1); | |
type r11 = __sync_fetch_and_sub_8(x, 1); | |
type r12 = __sync_fetch_and_or_8(x, 1); | |
type r13 = __sync_fetch_and_and_8(x, 1); | |
type r14 = __sync_fetch_and_xor_8(x, 1); | |
type r15 = __sync_fetch_and_nand_8(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_8(x, 1); | |
type r23 = __sync_sub_and_fetch_8(x, 1); | |
type r24 = __sync_or_and_fetch_8(x, 1); | |
type r25 = __sync_and_and_fetch_8(x, 1); | |
type r26 = __sync_xor_and_fetch_8(x, 1); | |
type r27 = __sync_nand_and_fetch_8(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_8(x, 1); | |
__sync_lock_release_8(x); | |
delete x; | |
} | |
{ | |
typedef int64_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_8(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_8(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_8(x, 1); | |
type r11 = __sync_fetch_and_sub_8(x, 1); | |
type r12 = __sync_fetch_and_or_8(x, 1); | |
type r13 = __sync_fetch_and_and_8(x, 1); | |
type r14 = __sync_fetch_and_xor_8(x, 1); | |
type r15 = __sync_fetch_and_nand_8(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_8(x, 1); | |
type r23 = __sync_sub_and_fetch_8(x, 1); | |
type r24 = __sync_or_and_fetch_8(x, 1); | |
type r25 = __sync_and_and_fetch_8(x, 1); | |
type r26 = __sync_xor_and_fetch_8(x, 1); | |
type r27 = __sync_nand_and_fetch_8(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_8(x, 1); | |
__sync_lock_release_8(x); | |
delete x; | |
} | |
{ | |
typedef __uint128_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_16(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_16(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_16(x, 1); | |
type r11 = __sync_fetch_and_sub_16(x, 1); | |
type r12 = __sync_fetch_and_or_16(x, 1); | |
type r13 = __sync_fetch_and_and_16(x, 1); | |
type r14 = __sync_fetch_and_xor_16(x, 1); | |
type r15 = __sync_fetch_and_nand_16(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_16(x, 1); | |
type r23 = __sync_sub_and_fetch_16(x, 1); | |
type r24 = __sync_or_and_fetch_16(x, 1); | |
type r25 = __sync_and_and_fetch_16(x, 1); | |
type r26 = __sync_xor_and_fetch_16(x, 1); | |
type r27 = __sync_nand_and_fetch_16(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_16(x, 1); | |
__sync_lock_release_16(x); | |
delete x; | |
} | |
{ | |
typedef __int128_t type; | |
type* x = new type(0); | |
bool r0 = __sync_bool_compare_and_swap(x, 0, 1); | |
type r1 = __sync_val_compare_and_swap(x, 1, 0); | |
bool r2 = __sync_bool_compare_and_swap_16(x, 0, 1); | |
type r3 = __sync_val_compare_and_swap_16(x, 1, 0); | |
type r4 = __sync_fetch_and_add(x, 1); | |
type r5 = __sync_fetch_and_sub(x, 1); | |
type r6 = __sync_fetch_and_or(x, 1); | |
type r7 = __sync_fetch_and_and(x, 1); | |
type r8 = __sync_fetch_and_xor(x, 1); | |
type r9 = __sync_fetch_and_nand(x, 1); | |
type r10 = __sync_fetch_and_add_16(x, 1); | |
type r11 = __sync_fetch_and_sub_16(x, 1); | |
type r12 = __sync_fetch_and_or_16(x, 1); | |
type r13 = __sync_fetch_and_and_16(x, 1); | |
type r14 = __sync_fetch_and_xor_16(x, 1); | |
type r15 = __sync_fetch_and_nand_16(x, 1); | |
type r16 = __sync_add_and_fetch(x, 1); | |
type r17 = __sync_sub_and_fetch(x, 1); | |
type r18 = __sync_or_and_fetch(x, 1); | |
type r19 = __sync_and_and_fetch(x, 1); | |
type r20 = __sync_xor_and_fetch(x, 1); | |
type r21 = __sync_nand_and_fetch(x, 1); | |
type r22 = __sync_add_and_fetch_16(x, 1); | |
type r23 = __sync_sub_and_fetch_16(x, 1); | |
type r24 = __sync_or_and_fetch_16(x, 1); | |
type r25 = __sync_and_and_fetch_16(x, 1); | |
type r26 = __sync_xor_and_fetch_16(x, 1); | |
type r27 = __sync_nand_and_fetch_16(x, 1); | |
type r28 = __sync_lock_test_and_set(x, 1); | |
__sync_lock_release(x); | |
type r29 = __sync_lock_test_and_set_16(x, 1); | |
__sync_lock_release_16(x); | |
delete x; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment