]>
Commit | Line | Data |
---|---|---|
86951993 AM |
1 | /* Supply a set of generic atomic functions to test the compiler make the |
2 | calls properly. */ | |
3 | /* { dg-do compile } */ | |
4 | /* { dg-options "-w" } */ | |
5 | ||
6 | /* Test that the generic builtins make calls as expected. This file provides | |
7 | the exact entry points the test file will require. All these routines | |
8 | simply set the first parameter to 1, and the caller will test for that. */ | |
9 | ||
ac3d02e2 | 10 | #include <stddef.h> |
86951993 AM |
11 | #include <stdlib.h> |
12 | #include <stdbool.h> | |
13 | #include <string.h> | |
14 | ||
15 | ||
16 | char | |
17 | __atomic_exchange_1 (char *p, char t, int i) | |
18 | { | |
19 | *p = 1; | |
20 | } | |
21 | ||
22 | short | |
23 | __atomic_load_2 (short *p, int i) | |
24 | { | |
25 | *p = 1; | |
26 | } | |
27 | ||
28 | void | |
29 | __atomic_store_1 (char *p, char v, int i) | |
30 | { | |
31 | *p = 1; | |
32 | } | |
33 | ||
e351ae85 | 34 | int __atomic_compare_exchange_2 (short *p, short *a, short b, int y, int z) |
86951993 | 35 | { |
e351ae85 AM |
36 | /* Fail if the memory models aren't correct as that will indicate the external |
37 | call has failed to remove the weak/strong parameter as required by the | |
38 | library. */ | |
39 | if (y != __ATOMIC_SEQ_CST || z != __ATOMIC_ACQUIRE) | |
40 | *p = 0; | |
41 | else | |
42 | *p = 1; | |
86951993 AM |
43 | } |
44 | ||
45 | char __atomic_fetch_add_1 (char *p, char v, int i) | |
46 | { | |
47 | *p = 1; | |
48 | } | |
49 | ||
154b68db | 50 | short __atomic_fetch_add_2 (short *p, short v, int i) |
86951993 AM |
51 | { |
52 | *p = 1; | |
53 | } | |
54 | ||
154b68db AM |
55 | /* Really perform a NAND. PR51040 showed incorrect calculation of a |
56 | non-inlined fetch_nand. */ | |
57 | unsigned char | |
58 | __atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i) | |
59 | { | |
60 | unsigned char ret; | |
61 | ||
62 | ret = *p; | |
63 | *p = ~(*p & v); | |
64 | ||
65 | return ret; | |
66 | } | |
67 | ||
ac3d02e2 | 68 | bool __atomic_is_lock_free (size_t i, void *p) |
86951993 | 69 | { |
f6c15759 EB |
70 | *(short *)p = 1; |
71 | return true; | |
86951993 | 72 | } |