]>
Commit | Line | Data |
---|---|---|
a945c346 | 1 | /* Copyright (C) 2012-2024 Free Software Foundation, Inc. |
9597375a OE |
2 | |
3 | This file is part of GCC. | |
4 | ||
5 | GCC is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3, or (at your option) | |
8 | any later version. | |
9 | ||
10 | GCC is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | Under Section 7 of GPL version 3, you are granted additional | |
16 | permissions described in the GCC Runtime Library Exception, version | |
17 | 3.1, as published by the Free Software Foundation. | |
18 | ||
19 | You should have received a copy of the GNU General Public License and | |
20 | a copy of the GCC Runtime Library Exception along with this program; | |
21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
22 | <http://www.gnu.org/licenses/>. */ | |
23 | ||
24 | /* Atomic built-in C functions for link compatibility with older code that | |
25 | was compiled to emit function calls for atomic built-ins. | |
26 | Notice that if no atomic model has been selected the functions in this | |
27 | file must not be generated, or else they will result in infinite no-op | |
28 | loops. | |
29 | Notice also, that all the generated functions below take three parameters, | |
30 | which is not actually true for some of the built-in functions. However, | |
31 | on SH this does not matter, since the first four parameters are always | |
32 | passed in call clobbered registers. | |
33 | The return type for the sync_bool_compare_and_swap functions is also | |
34 | actually supposed to be a bool, but this also doesn't matter since any | |
35 | int return type <= 32 bit is returned in R0 on SH. */ | |
36 | ||
37 | #if !__SH_ATOMIC_MODEL_NONE__ | |
38 | ||
39 | typedef unsigned char uint8_t; | |
40 | typedef unsigned short uint16_t; | |
41 | typedef unsigned int uint32_t; | |
42 | ||
43 | #define uint8_t_sz 1 | |
44 | #define uint16_t_sz 2 | |
45 | #define uint32_t_sz 4 | |
46 | ||
47 | #define typesz(x) x##_sz | |
48 | ||
49 | #define concat(x,y) __ ## x ## _ ## y | |
50 | #define eval(x,y) concat (x,y) | |
51 | #define genname(f,t) eval(f, typesz (t)) | |
52 | ||
53 | #define func1(name, type) \ | |
54 | type __attribute__((visibility("hidden"))) \ | |
55 | genname (name, type) (type* x, type y, type z) \ | |
56 | { \ | |
57 | return __##name (x, y, z); \ | |
58 | } | |
59 | ||
60 | #define genfuncs(name) \ | |
61 | func1 (name, uint8_t) \ | |
62 | func1 (name, uint16_t) \ | |
63 | func1 (name, uint32_t) | |
64 | ||
65 | genfuncs (sync_lock_test_and_set) | |
66 | genfuncs (sync_val_compare_and_swap) | |
67 | genfuncs (sync_bool_compare_and_swap) | |
68 | genfuncs (sync_fetch_and_add) | |
69 | genfuncs (sync_fetch_and_or) | |
70 | genfuncs (sync_fetch_and_and) | |
71 | genfuncs (sync_fetch_and_xor) | |
72 | genfuncs (sync_fetch_and_sub) | |
73 | genfuncs (sync_fetch_and_nand) | |
74 | genfuncs (sync_add_and_fetch) | |
75 | genfuncs (sync_or_and_fetch) | |
76 | genfuncs (sync_and_and_fetch) | |
77 | genfuncs (sync_xor_and_fetch) | |
78 | genfuncs (sync_sub_and_fetch) | |
79 | genfuncs (sync_nand_and_fetch) | |
80 | ||
81 | #endif |