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-1.c] - Blame information for rev 801

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

powered by: WebSVN 2.1.0

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