* gcc.dg/const-elim-1.c: xfail for xtensa.
[official-gcc.git] / gcc / testsuite / gcc.dg / ia64-sync-3.c
blobe718c1115e2928d341ab66d6a32397df943141cd
1 /* { dg-do run { target ia64-*-* } } */
2 /* { dg-options } */
4 /* Test basic functionality of the intrinsics. */
6 #include <ia64intrin.h>
8 static int AI[4];
9 static int init_si[4] = { -30,-30,-50,-50 };
10 static int test_si[4] = { -115,-115,25,25 };
12 static void
13 do_si (void)
15 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30)
16 abort ();
17 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115)
18 abort ();
19 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1)
20 abort ();
21 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0)
22 abort ();
24 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50)
25 abort ();
26 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25)
27 abort ();
28 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
29 abort ();
30 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
31 abort ();
34 static long AL[4];
35 static long init_di[4] = { -30,-30,-50,-50 };
36 static long test_di[4] = { -115,-115,25,25 };
38 static void
39 do_di (void)
41 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30)
42 abort ();
43 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115)
44 abort ();
45 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1)
46 abort ();
47 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0)
48 abort ();
50 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50)
51 abort ();
52 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25)
53 abort ();
54 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
55 abort ();
56 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
57 abort ();
60 int main()
62 memcpy(AI, init_si, sizeof(init_si));
63 memcpy(AL, init_di, sizeof(init_di));
65 do_si ();
66 do_di ();
68 if (memcmp (AI, test_si, sizeof(test_si)))
69 abort ();
70 if (memcmp (AL, test_di, sizeof(test_di)))
71 abort ();
73 return 0;