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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [atomic-generic.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 generic __atomic routines for proper function calling.
2
   memory model.  */
3
/* { dg-options "-w" } */
4
/* { dg-do run } */
5
/* { dg-additional-sources "atomic-generic-aux.c" } */
6
 
7
/* Test that the generioc atomic builtins execute as expected..
8
   sync-mem-generic-aux.c supplies a functional external entry point for
9
   the 4 generic functions.  */
10
 
11
#include <stdlib.h>
12
#include <stdbool.h>
13
 
14
extern void abort();
15
 
16
typedef struct test {
17
  int array[10];
18
} test_struct;
19
 
20
test_struct zero = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
21
test_struct ones = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
22
test_struct a,b;
23
 
24
int size = sizeof (test_struct);
25
/* Test for consistency on sizes 1, 2, 4, 8, 16 and 32.  */
26
main ()
27
{
28
  test_struct c;
29
 
30
  __atomic_store (&a, &zero, __ATOMIC_RELAXED);
31
  if (memcmp (&a, &zero, size))
32
    abort ();
33
 
34
  __atomic_exchange (&a, &ones, &c, __ATOMIC_SEQ_CST);
35
  if (memcmp (&c, &zero, size))
36
    abort ();
37
  if (memcmp (&a, &ones, size))
38
    abort ();
39
 
40
  __atomic_load (&a, &b, __ATOMIC_RELAXED);
41
  if (memcmp (&b, &ones, size))
42
    abort ();
43
 
44
  if (!__atomic_compare_exchange (&a, &b, &zero, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
45
    abort();
46
  if (memcmp (&a, &zero, size))
47
    abort ();
48
 
49
  if (__atomic_compare_exchange (&a, &b, &ones, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
50
    abort();
51
  if (memcmp (&b, &zero, size))
52
    abort ();
53
 
54
  return 0;
55
}
56
 

powered by: WebSVN 2.1.0

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