Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / ia64-sync-3.c
blob965d4359e8629da21fd4dc1e88e89bea31fa0909
1 /* { dg-do run } */
2 /* { dg-require-effective-target sync_int_long } */
3 /* { dg-options } */
4 /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
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);
14 static int AI[4];
15 static int init_si[4] = { -30,-30,-50,-50 };
16 static int test_si[4] = { -115,-115,25,25 };
18 static void
19 do_si (void)
21 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30)
22 abort ();
23 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115)
24 abort ();
25 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1)
26 abort ();
27 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0)
28 abort ();
30 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50)
31 abort ();
32 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25)
33 abort ();
34 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
35 abort ();
36 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
37 abort ();
40 static long AL[4];
41 static long init_di[4] = { -30,-30,-50,-50 };
42 static long test_di[4] = { -115,-115,25,25 };
44 static void
45 do_di (void)
47 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30)
48 abort ();
49 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115)
50 abort ();
51 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1)
52 abort ();
53 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0)
54 abort ();
56 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50)
57 abort ();
58 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25)
59 abort ();
60 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
61 abort ();
62 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
63 abort ();
66 int main()
68 memcpy(AI, init_si, sizeof(init_si));
69 memcpy(AL, init_di, sizeof(init_di));
71 do_si ();
72 do_di ();
74 if (memcmp (AI, test_si, sizeof(test_si)))
75 abort ();
76 if (memcmp (AL, test_di, sizeof(test_di)))
77 abort ();
79 return 0;