OSDN Git Service

Index: gcc/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / ia64-sync-3.c
1 /* { dg-do run { target ia64-*-* } } */
2 /* { dg-options } */
3
4 /* Test basic functionality of the intrinsics.  */
5
6 #include <ia64intrin.h>
7
8 extern void abort (void);
9 extern void *memcpy (void *, const void *, __SIZE_TYPE__);
10
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 };
14
15 static void
16 do_si (void)
17 {
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 ();
26
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 ();
35 }
36
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 };
40
41 static void
42 do_di (void)
43 {
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 ();
52
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 ();
61 }
62
63 int main()
64 {
65   memcpy(AI, init_si, sizeof(init_si));
66   memcpy(AL, init_di, sizeof(init_di));
67
68   do_si ();
69   do_di ();
70
71   if (memcmp (AI, test_si, sizeof(test_si)))
72     abort ();
73   if (memcmp (AL, test_di, sizeof(test_di)))
74     abort ();
75
76   return 0;
77 }