2 /* { dg-require-effective-target sync_char_short } */
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 /* This is a copy of gcc.dg/ia64-sync-3.c, for 8-bit and 16-bit. */
11 __extension__
typedef __SIZE_TYPE__
size_t;
13 extern void abort (void);
14 extern void *memcpy (void *, const void *, size_t);
15 extern int memcmp (const void *, const void *, size_t);
17 static signed char AC
[4];
18 static signed char init_qi
[4] = { -30,-30,-50,-50 };
19 static signed char test_qi
[4] = { -115,-115,25,25 };
24 if (__sync_val_compare_and_swap(AC
+0, -30, -115) != -30)
26 if (__sync_val_compare_and_swap(AC
+0, -30, -115) != -115)
28 if (__sync_bool_compare_and_swap(AC
+1, -30, -115) != 1)
30 if (__sync_bool_compare_and_swap(AC
+1, -30, -115) != 0)
33 if (__sync_val_compare_and_swap(AC
+2, AC
[2], 25) != -50)
35 if (__sync_val_compare_and_swap(AC
+2, AC
[2], 25) != 25)
37 if (__sync_bool_compare_and_swap(AC
+3, AC
[3], 25) != 1)
39 if (__sync_bool_compare_and_swap(AC
+3, AC
[3], 25) != 1)
44 static short init_hi
[4] = { -30,-30,-50,-50 };
45 static short test_hi
[4] = { -115,-115,25,25 };
50 if (__sync_val_compare_and_swap(AS
+0, -30, -115) != -30)
52 if (__sync_val_compare_and_swap(AS
+0, -30, -115) != -115)
54 if (__sync_bool_compare_and_swap(AS
+1, -30, -115) != 1)
56 if (__sync_bool_compare_and_swap(AS
+1, -30, -115) != 0)
59 if (__sync_val_compare_and_swap(AS
+2, AS
[2], 25) != -50)
61 if (__sync_val_compare_and_swap(AS
+2, AS
[2], 25) != 25)
63 if (__sync_bool_compare_and_swap(AS
+3, AS
[3], 25) != 1)
65 if (__sync_bool_compare_and_swap(AS
+3, AS
[3], 25) != 1)
71 memcpy(AC
, init_qi
, sizeof(init_qi
));
72 memcpy(AS
, init_hi
, sizeof(init_hi
));
77 if (memcmp (AC
, test_qi
, sizeof(test_qi
)))
79 if (memcmp (AS
, test_hi
, sizeof(test_hi
)))