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

Subversion Repositories openrisc

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

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 4 byte
2
   values with each valid memory model.  */
3
/* { dg-do run } */
4
/* { dg-require-effective-target sync_int_long } */
5
 
6
/* Test the execution of the __atomic_X builtin for an int.  */
7
 
8
extern void abort(void);
9
 
10
int v, count, ret;
11
 
12
main ()
13
{
14
  v = 0;
15
  count = 0;
16
 
17
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) !=  count++)
18
    abort ();
19
 
20
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) !=  count++)
21
    abort ();
22
 
23
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) !=  count++)
24
    abort ();
25
 
26
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) !=  count++)
27
    abort ();
28
 
29
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) !=  count++)
30
    abort ();
31
 
32
  /* Now test the generic version.  */
33
 
34
  count++;
35
 
36
  __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
37
  if (ret != count - 1 || v != count)
38
    abort ();
39
  count++;
40
 
41
  __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
42
  if (ret != count - 1 || v != count)
43
    abort ();
44
  count++;
45
 
46
  __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
47
  if (ret != count - 1 || v != count)
48
    abort ();
49
  count++;
50
 
51
  __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
52
  if (ret != count - 1 || v != count)
53
    abort ();
54
  count++;
55
 
56
  __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
57
  if (ret != count - 1 || v != count)
58
    abort ();
59
  count++;
60
 
61
  return 0;
62
}

powered by: WebSVN 2.1.0

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