OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [ia64-sync-2.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { 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*-*-* } } */
6
 
7
/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */
8
/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */
9
 
10
/* Test basic functionality of the intrinsics.  */
11
 
12
__extension__ typedef __SIZE_TYPE__ size_t;
13
 
14
extern void abort (void);
15
extern void *memcpy (void *, const void *, size_t);
16
 
17
static int AI[18];
18
static int init_si[18] = { 0,0,0,1,0,0, 0,0  ,-1,0,0,-1,0,0  ,-1,0,0,-1 };
19
static int test_si[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 };
20
 
21
static void
22
do_si (void)
23
{
24
  if (__sync_val_compare_and_swap(AI+0, 0, 1) != 0)
25
    abort ();
26
  if (__sync_val_compare_and_swap(AI+0, 0, 1) != 1)
27
    abort ();
28
  if (__sync_bool_compare_and_swap(AI+1, 0, 1) != 1)
29
    abort ();
30
  if (__sync_bool_compare_and_swap(AI+1, 0, 1) != 0)
31
    abort ();
32
 
33
  if (__sync_lock_test_and_set(AI+2, 1) != 0)
34
    abort ();
35
 
36
  if (__sync_fetch_and_add(AI+4, 1) != 0)
37
    abort ();
38
  if (__sync_fetch_and_add(AI+5, 4) != 0)
39
    abort ();
40
  if (__sync_fetch_and_add(AI+6, 22) != 0)
41
    abort ();
42
  if (__sync_fetch_and_sub(AI+7, 12) != 0)
43
    abort ();
44
  if (__sync_fetch_and_and(AI+8, 7) != -1)
45
    abort ();
46
  if (__sync_fetch_and_or(AI+9, 8) != 0)
47
    abort ();
48
  if (__sync_fetch_and_xor(AI+10, 9) != 0)
49
    abort ();
50
  if (__sync_fetch_and_nand(AI+11, 7) != -1)
51
    abort ();
52
 
53
  if (__sync_add_and_fetch(AI+12, 1) != 1)
54
    abort ();
55
  if (__sync_sub_and_fetch(AI+13, 12) != -12)
56
    abort ();
57
  if (__sync_and_and_fetch(AI+14, 7) != 7)
58
    abort ();
59
  if (__sync_or_and_fetch(AI+15, 8) != 8)
60
    abort ();
61
  if (__sync_xor_and_fetch(AI+16, 9) != 9)
62
    abort ();
63
  if (__sync_nand_and_fetch(AI+17, 7) != ~7)
64
    abort ();
65
}
66
 
67
static long AL[18];
68
static long init_di[18] = { 0,0,0,1,0,0, 0,0  ,-1,0,0,-1,0,0  ,-1,0,0,-1 };
69
static long test_di[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 };
70
 
71
static void
72
do_di (void)
73
{
74
  if (__sync_val_compare_and_swap(AL+0, 0, 1) != 0)
75
    abort ();
76
  if (__sync_val_compare_and_swap(AL+0, 0, 1) != 1)
77
    abort ();
78
  if (__sync_bool_compare_and_swap(AL+1, 0, 1) != 1)
79
    abort ();
80
  if (__sync_bool_compare_and_swap(AL+1, 0, 1) != 0)
81
    abort ();
82
 
83
  if (__sync_lock_test_and_set(AL+2, 1) != 0)
84
    abort ();
85
 
86
  if (__sync_fetch_and_add(AL+4, 1) != 0)
87
    abort ();
88
  if (__sync_fetch_and_add(AL+5, 4) != 0)
89
    abort ();
90
  if (__sync_fetch_and_add(AL+6, 22) != 0)
91
    abort ();
92
  if (__sync_fetch_and_sub(AL+7, 12) != 0)
93
    abort ();
94
  if (__sync_fetch_and_and(AL+8, 7) != -1)
95
    abort ();
96
  if (__sync_fetch_and_or(AL+9, 8) != 0)
97
    abort ();
98
  if (__sync_fetch_and_xor(AL+10, 9) != 0)
99
    abort ();
100
  if (__sync_fetch_and_nand(AL+11, 7) != -1)
101
    abort ();
102
 
103
  if (__sync_add_and_fetch(AL+12, 1) != 1)
104
    abort ();
105
  if (__sync_sub_and_fetch(AL+13, 12) != -12)
106
    abort ();
107
  if (__sync_and_and_fetch(AL+14, 7) != 7)
108
    abort ();
109
  if (__sync_or_and_fetch(AL+15, 8) != 8)
110
    abort ();
111
  if (__sync_xor_and_fetch(AL+16, 9) != 9)
112
    abort ();
113
  if (__sync_nand_and_fetch(AL+17, 7) != ~7)
114
    abort ();
115
}
116
 
117
int main()
118
{
119
  memcpy(AI, init_si, sizeof(init_si));
120
  memcpy(AL, init_di, sizeof(init_di));
121
 
122
  do_si ();
123
  do_di ();
124
 
125
  if (memcmp (AI, test_si, sizeof(test_si)))
126
    abort ();
127
  if (memcmp (AL, test_di, sizeof(test_di)))
128
    abort ();
129
 
130
  return 0;
131
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.