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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [atomic-lockfree.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 execution with each valid
2
   memory model.  */
3
/* { dg-options "-w" } */
4
/* { dg-do run } */
5
/* { dg-additional-sources "atomic-lockfree-aux.c" } */
6
 
7
/* Test that __atomic_{is,always}_lock_free builtins execute.
8
   sync-mem-lockfree-aux.c supplies and external entry point for
9
   __atomic_is_lock_free which always returns a 2. We can detect the
10
   external routine was called if 2 is returned since that is not a valid
11
   result normally.  */
12
 
13
#include <stdlib.h>
14
 
15
extern void abort();
16
 
17
int r1, r2;
18
 
19
/* Test for consistency on sizes 1, 2, 4, 8, 16 and 32.  */
20
main ()
21
{
22
 
23
  r1 = __atomic_always_lock_free (sizeof(char), 0);
24
  r2 = __atomic_is_lock_free (sizeof(char), 0);
25
  /* If always lock free, then is_lock_free must also be true.  */
26
  if (r1)
27
    {
28
      if (r2 != 1)
29
        abort ();
30
    }
31
  else
32
    {
33
      /* If it is not lock free, then the external routine must be called.  */
34
      if (r2 != 2)
35
        abort ();
36
    }
37
 
38
  r1 = __atomic_always_lock_free (2, 0);
39
  r2 = __atomic_is_lock_free (2, 0);
40
  /* If always lock free, then is_lock_free must also be true.  */
41
  if (r1)
42
    {
43
      if (r2 != 1)
44
        abort ();
45
    }
46
  else
47
    {
48
      /* If it is not lock free, then the external routine must be called.  */
49
      if (r2 != 2)
50
        abort ();
51
    }
52
 
53
 
54
  r1 = __atomic_always_lock_free (4, 0);
55
  r2 = __atomic_is_lock_free (4, 0);     /* Try passing in a variable.  */
56
  /* If always lock free, then is_lock_free must also be true.  */
57
  if (r1)
58
    {
59
      if (r2 != 1)
60
        abort ();
61
    }
62
  else
63
    {
64
      /* If it is not lock free, then the external routine must be called.  */
65
      if (r2 != 2)
66
        abort ();
67
    }
68
 
69
 
70
  r1 = __atomic_always_lock_free (8, 0);
71
  r2 = __atomic_is_lock_free (8, 0);
72
  /* If always lock free, then is_lock_free must also be true.  */
73
  if (r1)
74
    {
75
      if (r2 != 1)
76
        abort ();
77
    }
78
  else
79
    {
80
      /* If it is not lock free, then the external routine must be called.  */
81
      if (r2 != 2)
82
        abort ();
83
    }
84
 
85
 
86
  r1 = __atomic_always_lock_free (16, 0);
87
  r2 = __atomic_is_lock_free (16, 0);
88
  /* If always lock free, then is_lock_free must also be true.  */
89
  if (r1)
90
    {
91
      if (r2 != 1)
92
        abort ();
93
    }
94
  else
95
    {
96
      /* If it is not lock free, then the external routine must be called.  */
97
      if (r2 != 2)
98
        abort ();
99
    }
100
 
101
 
102
  r1 = __atomic_always_lock_free (32, 0);
103
  r2 = __atomic_is_lock_free (32, 0);
104
  /* If always lock free, then is_lock_free must also be true.  */
105
  if (r1)
106
    {
107
      if (r2 != 1)
108
        abort ();
109
    }
110
  else
111
    {
112
      /* If it is not lock free, then the external routine must be called.  */
113
      if (r2 != 2)
114
        abort ();
115
    }
116
 
117
 
118
  return 0;
119
}
120
 

powered by: WebSVN 2.1.0

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