2 /* { dg-require-effective-target sync_int_long } */
4 /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
5 /* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
7 /* Test basic functionality of the intrinsics. */
9 __extension__
typedef __SIZE_TYPE__
size_t;
11 extern void abort (void);
12 extern void *memcpy (void *, const void *, size_t);
15 static int init_si
[4] = { -30,-30,-50,-50 };
16 static int test_si
[4] = { -115,-115,25,25 };
21 if (__sync_val_compare_and_swap(AI
+0, -30, -115) != -30)
23 if (__sync_val_compare_and_swap(AI
+0, -30, -115) != -115)
25 if (__sync_bool_compare_and_swap(AI
+1, -30, -115) != 1)
27 if (__sync_bool_compare_and_swap(AI
+1, -30, -115) != 0)
30 if (__sync_val_compare_and_swap(AI
+2, AI
[2], 25) != -50)
32 if (__sync_val_compare_and_swap(AI
+2, AI
[2], 25) != 25)
34 if (__sync_bool_compare_and_swap(AI
+3, AI
[3], 25) != 1)
36 if (__sync_bool_compare_and_swap(AI
+3, AI
[3], 25) != 1)
41 static long init_di
[4] = { -30,-30,-50,-50 };
42 static long test_di
[4] = { -115,-115,25,25 };
47 if (__sync_val_compare_and_swap(AL
+0, -30, -115) != -30)
49 if (__sync_val_compare_and_swap(AL
+0, -30, -115) != -115)
51 if (__sync_bool_compare_and_swap(AL
+1, -30, -115) != 1)
53 if (__sync_bool_compare_and_swap(AL
+1, -30, -115) != 0)
56 if (__sync_val_compare_and_swap(AL
+2, AL
[2], 25) != -50)
58 if (__sync_val_compare_and_swap(AL
+2, AL
[2], 25) != 25)
60 if (__sync_bool_compare_and_swap(AL
+3, AL
[3], 25) != 1)
62 if (__sync_bool_compare_and_swap(AL
+3, AL
[3], 25) != 1)
68 memcpy(AI
, init_si
, sizeof(init_si
));
69 memcpy(AL
, init_di
, sizeof(init_di
));
74 if (memcmp (AI
, test_si
, sizeof(test_si
)))
76 if (memcmp (AL
, test_di
, sizeof(test_di
)))