aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
blob: deab7ae1de36ff85532c4bc4181ef4996cbc604d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Supply a set of generic atomic functions to test the compiler make the
   calls properly.  */
/* { dg-do compile } */
/* { dg-options "-w" } */

/* Test that the generic builtins make calls as expected.  This file provides
   the exact entry points the test file will require.  All these routines
   simply set the first parameter to 1, and the caller will test for that.  */

#include <stdlib.h>
#include <stdbool.h>
#include <string.h>


char 
__atomic_exchange_1 (char *p, char t, int i)
{
  *p = 1;
}

short
__atomic_load_2 (short *p, int i)
{ 
  *p = 1;
}

void
__atomic_store_1 (char *p, char v, int i)
{
  *p = 1;
}

int __atomic_compare_exchange_2 (short *p, short *a, short b, int y, int z)
{
  /* Fail if the memory models aren't correct as that will indicate the external
     call has failed to remove the weak/strong parameter as required by the
     library.  */
  if (y != __ATOMIC_SEQ_CST || z != __ATOMIC_ACQUIRE)
    *p = 0;
  else
    *p = 1;
}

char __atomic_fetch_add_1 (char *p, char v, int i)
{
  *p = 1;
}

short __atomic_fetch_add_2 (short *p, short v, int i)
{
  *p = 1;
}

/* Really perform a NAND.  PR51040 showed incorrect calculation of a 
   non-inlined fetch_nand.  */
unsigned char 
__atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i)
{
  unsigned char ret;

  ret = *p;
  *p = ~(*p & v);

  return ret;
}

int __atomic_is_lock_free (int i, void *p)
{
  return 10;
}