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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [atomic-noinline.c] - Blame information for rev 698

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 -fno-inline-atomics" } */
4
/* { dg-do run } */
5
/* { dg-additional-sources "atomic-noinline-aux.c" } */
6
 
7
/* Test that -fno-inline-atomics works as expected.
8
   atomic-generic-aux provide the expected routines which simply set the
9
   value of the first parameter to */
10
 
11
#include <stdlib.h>
12
#include <stdbool.h>
13
 
14
extern void abort();
15
 
16
short as,bs,cs;
17
char ac,bc,cc;
18
 
19
main ()
20
{
21
 
22
  ac = __atomic_exchange_n (&bc, cc, __ATOMIC_RELAXED);
23
  if (bc != 1)
24
    abort ();
25
 
26
  as = __atomic_load_n (&bs, __ATOMIC_SEQ_CST);
27
  if (bs != 1)
28
    abort ();
29
 
30
  __atomic_store_n (&ac, bc, __ATOMIC_RELAXED);
31
  if (ac != 1)
32
    abort ();
33
 
34
  __atomic_compare_exchange_n (&as, &bs, cs, 0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
35
  if (as != 1)
36
    abort ();
37
 
38
  ac = __atomic_fetch_add (&cc, 15, __ATOMIC_SEQ_CST);
39
  if (cc != 1)
40
    abort ();
41
 
42
  /* This should be translated to __atomic_fetch_add for the library */
43
  as = __atomic_add_fetch (&cs, 10, __ATOMIC_RELAXED);
44
 
45
  if (cs != 1)
46
    abort ();
47
 
48
  /* The fake external function should return 10.  */
49
  if (__atomic_is_lock_free (4, 0) != 10)
50
    abort ();
51
 
52
  /* PR 51040 was caused by arithmetic code not patching up nand_fetch properly
53
     when used an an external function.  Look for proper return value here.  */
54
  ac = 0x3C;
55
  bc = __atomic_nand_fetch (&ac, 0x0f, __ATOMIC_RELAXED);
56
  if (bc != ac)
57
    abort ();
58
 
59
  return 0;
60
}
61
 
62
 
63
 

powered by: WebSVN 2.1.0

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