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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [atomic-compare-exchange-4.c] - Blame information for rev 701

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test __atomic routines for existence and proper execution on 8 byte
2
   values with each valid memory model.  */
3
/* { dg-do run } */
4
/* { dg-require-effective-target sync_long_long_runtime } */
5
/* { dg-options "" } */
6
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
7
 
8
/* Test the execution of __atomic_compare_exchange_n builtin for a long_long.  */
9
 
10
extern void abort(void);
11
 
12
long long v = 0;
13
long long expected = 0;
14
long long max = ~0;
15
long long desired = ~0;
16
long long zero = 0;
17
 
18
#define STRONG 0
19
#define WEAK 1
20
 
21
main ()
22
{
23
 
24
  if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
25
    abort ();
26
  if (expected != 0)
27
    abort ();
28
 
29
  if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
30
    abort ();
31
  if (expected != max)
32
    abort ();
33
 
34
  if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
35
    abort ();
36
  if (expected != max)
37
    abort ();
38
  if (v != 0)
39
    abort ();
40
 
41
  if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
42
    abort ();
43
  if (expected != 0)
44
    abort ();
45
 
46
  if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
47
    abort ();
48
  if (expected != 0)
49
    abort ();
50
  if (v != max)
51
    abort ();
52
 
53
  /* Now test the generic version.  */
54
 
55
  v = 0;
56
 
57
  if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
58
    abort ();
59
  if (expected != 0)
60
    abort ();
61
 
62
  if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
63
    abort ();
64
  if (expected != max)
65
    abort ();
66
 
67
  if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
68
    abort ();
69
  if (expected != max)
70
    abort ();
71
  if (v != 0)
72
    abort ();
73
 
74
  if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
75
    abort ();
76
  if (expected != 0)
77
    abort ();
78
 
79
  if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
80
    abort ();
81
  if (expected != 0)
82
    abort ();
83
  if (v != max)
84
    abort ();
85
 
86
  return 0;
87
}

powered by: WebSVN 2.1.0

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