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

Subversion Repositories openrisc

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

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 the __atomic_X builtin for a long_long.  */
9
 
10
extern void abort(void);
11
 
12
long long v, count, ret;
13
 
14
main ()
15
{
16
  v = 0;
17
  count = 0;
18
 
19
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) !=  count++)
20
    abort ();
21
 
22
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) !=  count++)
23
    abort ();
24
 
25
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) !=  count++)
26
    abort ();
27
 
28
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) !=  count++)
29
    abort ();
30
 
31
  if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) !=  count++)
32
    abort ();
33
 
34
  /* Now test the generic version.  */
35
 
36
  count++;
37
 
38
  __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
39
  if (ret != count - 1 || v != count)
40
    abort ();
41
  count++;
42
 
43
  __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
44
  if (ret != count - 1 || v != count)
45
    abort ();
46
  count++;
47
 
48
  __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
49
  if (ret != count - 1 || v != count)
50
    abort ();
51
  count++;
52
 
53
  __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
54
  if (ret != count - 1 || v != count)
55
    abort ();
56
  count++;
57
 
58
  __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
59
  if (ret != count - 1 || v != count)
60
    abort ();
61
  count++;
62
 
63
  return 0;
64
}

powered by: WebSVN 2.1.0

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