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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [ia64-sync-3.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 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-*-* } && ia32 } } } */
5
/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
6
 
7
/* Test basic functionality of the intrinsics.  */
8
 
9
__extension__ typedef __SIZE_TYPE__ size_t;
10
 
11
extern void abort (void);
12
extern void *memcpy (void *, const void *, size_t);
13
 
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 };
17
 
18
static void
19
do_si (void)
20
{
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 ();
29
 
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 ();
38
}
39
 
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 };
43
 
44
static void
45
do_di (void)
46
{
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 ();
55
 
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 ();
64
}
65
 
66
int main()
67
{
68
  memcpy(AI, init_si, sizeof(init_si));
69
  memcpy(AL, init_di, sizeof(init_di));
70
 
71
  do_si ();
72
  do_di ();
73
 
74
  if (memcmp (AI, test_si, sizeof(test_si)))
75
    abort ();
76
  if (memcmp (AL, test_di, sizeof(test_di)))
77
    abort ();
78
 
79
  return 0;
80
}

powered by: WebSVN 2.1.0

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