Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / testsuite / gcc.dg / ia64-sync-3.c
blobc2772f759b6f9a635d323114e9c23a2a4683c9c1
1 /* { dg-do run { target ia64-*-* } } */
2 /* { dg-options } */
4 /* Test basic functionality of the intrinsics. */
6 #include <ia64intrin.h>
8 extern void abort (void);
9 extern void *memcpy (void *, const void *, __SIZE_TYPE__);
11 static int AI[4];
12 static int init_si[4] = { -30,-30,-50,-50 };
13 static int test_si[4] = { -115,-115,25,25 };
15 static void
16 do_si (void)
18 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30)
19 abort ();
20 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115)
21 abort ();
22 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1)
23 abort ();
24 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0)
25 abort ();
27 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50)
28 abort ();
29 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25)
30 abort ();
31 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
32 abort ();
33 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
34 abort ();
37 static long AL[4];
38 static long init_di[4] = { -30,-30,-50,-50 };
39 static long test_di[4] = { -115,-115,25,25 };
41 static void
42 do_di (void)
44 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30)
45 abort ();
46 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115)
47 abort ();
48 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1)
49 abort ();
50 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0)
51 abort ();
53 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50)
54 abort ();
55 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25)
56 abort ();
57 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
58 abort ();
59 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
60 abort ();
63 int main()
65 memcpy(AI, init_si, sizeof(init_si));
66 memcpy(AL, init_di, sizeof(init_di));
68 do_si ();
69 do_di ();
71 if (memcmp (AI, test_si, sizeof(test_si)))
72 abort ();
73 if (memcmp (AL, test_di, sizeof(test_di)))
74 abort ();
76 return 0;