Commit | Line | Data |
---|---|---|
d1854484 OD |
1 | /* |
2 | * urcu/uatomic/builtins.h | |
3 | * | |
4 | * Copyright (c) 2023 Olivier Dion <odion@efficios.com> | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2.1 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef _URCU_UATOMIC_BUILTINS_H | |
22 | #define _URCU_UATOMIC_BUILTINS_H | |
23 | ||
24 | #include <urcu/arch.h> | |
25 | ||
26 | #if defined(__has_builtin) | |
27 | # if !__has_builtin(__atomic_store_n) | |
28 | # error "Toolchain does not support __atomic_store_n." | |
29 | # endif | |
30 | # if !__has_builtin(__atomic_load_n) | |
31 | # error "Toolchain does not support __atomic_load_n." | |
32 | # endif | |
33 | # if !__has_builtin(__atomic_exchange_n) | |
34 | # error "Toolchain does not support __atomic_exchange_n." | |
35 | # endif | |
36 | # if !__has_builtin(__atomic_compare_exchange_n) | |
37 | # error "Toolchain does not support __atomic_compare_exchange_n." | |
38 | # endif | |
39 | # if !__has_builtin(__atomic_add_fetch) | |
40 | # error "Toolchain does not support __atomic_add_fetch." | |
41 | # endif | |
42 | # if !__has_builtin(__atomic_sub_fetch) | |
43 | # error "Toolchain does not support __atomic_sub_fetch." | |
44 | # endif | |
45 | # if !__has_builtin(__atomic_or_fetch) | |
46 | # error "Toolchain does not support __atomic_or_fetch." | |
47 | # endif | |
48 | # if !__has_builtin(__atomic_thread_fence) | |
49 | # error "Toolchain does not support __atomic_thread_fence." | |
50 | # endif | |
51 | # if !__has_builtin(__atomic_signal_fence) | |
52 | # error "Toolchain does not support __atomic_signal_fence." | |
53 | # endif | |
54 | #elif defined(__GNUC__) | |
55 | # define GCC_VERSION (__GNUC__ * 10000 + \ | |
56 | __GNUC_MINOR__ * 100 + \ | |
57 | __GNUC_PATCHLEVEL__) | |
58 | # if GCC_VERSION < 40700 | |
59 | # error "GCC version is too old. Version must be 4.7 or greater" | |
60 | # endif | |
61 | # undef GCC_VERSION | |
62 | #else | |
63 | # error "Toolchain is not supported." | |
64 | #endif | |
65 | ||
66 | #if defined(__GNUC__) | |
67 | # define UATOMIC_HAS_ATOMIC_BYTE __GCC_ATOMIC_CHAR_LOCK_FREE | |
68 | # define UATOMIC_HAS_ATOMIC_SHORT __GCC_ATOMIC_SHORT_LOCK_FREE | |
69 | #elif defined(__clang__) | |
70 | # define UATOMIC_HAS_ATOMIC_BYTE __CLANG_ATOMIC_CHAR_LOCK_FREE | |
71 | # define UATOMIC_HAS_ATOMIC_SHORT __CLANG_ATOMIC_SHORT_LOCK_FREE | |
72 | #else | |
73 | /* # define UATOMIC_HAS_ATOMIC_BYTE */ | |
74 | /* # define UATOMIC_HAS_ATOMIC_SHORT */ | |
75 | #endif | |
76 | ||
77 | #include <urcu/uatomic/builtins-generic.h> | |
78 | ||
79 | #endif /* _URCU_UATOMIC_BUILTINS_H */ |