1 1.1 christos // SPDX-FileCopyrightText: 2020 Michael Jeanson <mjeanson (at) efficios.com> 2 1.1 christos // 3 1.1 christos // SPDX-License-Identifier: LGPL-2.1-or-later 4 1.1 christos 5 1.1 christos #ifndef _URCU_ARCH_H 6 1.1 christos #define _URCU_ARCH_H 7 1.1 christos 8 1.1 christos /* 9 1.1 christos * Architecture detection using compiler defines. 10 1.1 christos * 11 1.1 christos * The following defines are used internally for architecture specific code. 12 1.1 christos * 13 1.1 christos * URCU_ARCH_X86 : All x86 variants 32 and 64 bits 14 1.1 christos * URCU_ARCH_I386 : Specific to the i386 15 1.1 christos * URCU_ARCH_AMD64 : All 64 bits x86 variants 16 1.1 christos * URCU_ARCH_K1OM : Specific to the Xeon Phi / MIC 17 1.1 christos * 18 1.1 christos * URCU_ARCH_PPC : All PowerPC variants 32 and 64 bits 19 1.1 christos * URCU_ARCH_PPC64 : Specific to 64 bits variants 20 1.1 christos * 21 1.1 christos * URCU_ARCH_S390 : All IBM s390 / s390x variants 22 1.1 christos * 23 1.1 christos * URCU_ARCH_SPARC64 : All Sun SPARC variants 24 1.1 christos * 25 1.1 christos * URCU_ARCH_ALPHA : All DEC Alpha variants 26 1.1 christos * URCU_ARCH_IA64 : All Intel Itanium variants 27 1.1 christos * URCU_ARCH_ARM : All ARM 32 bits variants 28 1.1 christos * URCU_ARCH_ARMV7 : All ARMv7 ISA variants 29 1.1 christos * URCU_ARCH_AARCH64 : All ARM 64 bits variants 30 1.1 christos * URCU_ARCH_MIPS : All MIPS variants 31 1.1 christos * URCU_ARCH_NIOS2 : All Intel / Altera NIOS II variants 32 1.1 christos * URCU_ARCH_TILE : All Tilera TILE variants 33 1.1 christos * URCU_ARCH_HPPA : All HP PA-RISC variants 34 1.1 christos * URCU_ARCH_M68K : All Motorola 68000 variants 35 1.1 christos * URCU_ARCH_RISCV : All RISC-V variants 36 1.1 christos * URCU_ARCH_LOONGARCH : All LoongArch variants 37 1.2 christos * URCU_ARCH_VAX : All DEC VAX variants 38 1.2 christos * URCU_ARCH_SH3 : All SUPER H 3 variants 39 1.1 christos */ 40 1.1 christos 41 1.1 christos #if (defined(__INTEL_OFFLOAD) || defined(__TARGET_ARCH_MIC) || defined(__MIC__)) 42 1.1 christos 43 1.1 christos #define URCU_ARCH_X86 1 44 1.1 christos #define URCU_ARCH_AMD64 1 45 1.1 christos #define URCU_ARCH_K1OM 1 46 1.1 christos #include <urcu/arch/x86.h> 47 1.1 christos 48 1.1 christos #elif (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)) 49 1.1 christos 50 1.1 christos #define URCU_ARCH_X86 1 51 1.1 christos #define URCU_ARCH_AMD64 1 52 1.1 christos #include <urcu/arch/x86.h> 53 1.1 christos 54 1.1 christos #elif (defined(__i386__) || defined(__i386)) 55 1.1 christos 56 1.1 christos #define URCU_ARCH_X86 1 57 1.1 christos 58 1.1 christos /* 59 1.1 christos * URCU_ARCH_X86_NO_CAS enables a compat layer that will detect the presence of 60 1.1 christos * the cmpxchg instructions at runtime and provide a compat mode based on a 61 1.1 christos * pthread mutex when it isn't. 62 1.1 christos * 63 1.1 christos * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 was introduced in GCC 4.3 and Clang 3.3, 64 1.1 christos * building with older compilers will result in the compat layer always being 65 1.1 christos * used on x86-32. 66 1.1 christos */ 67 1.1 christos #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 68 1.1 christos #define URCU_ARCH_X86_NO_CAS 1 69 1.1 christos /* For backwards compat */ 70 1.1 christos #define URCU_ARCH_I386 1 71 1.1 christos #endif 72 1.1 christos 73 1.1 christos #include <urcu/arch/x86.h> 74 1.1 christos 75 1.1 christos #elif (defined(__powerpc64__) || defined(__ppc64__)) 76 1.1 christos 77 1.1 christos #define URCU_ARCH_PPC 1 78 1.1 christos #define URCU_ARCH_PPC64 1 79 1.1 christos #include <urcu/arch/ppc.h> 80 1.1 christos 81 1.1 christos #elif (defined(__powerpc__) || defined(__powerpc) || defined(__ppc__)) 82 1.1 christos 83 1.1 christos #define URCU_ARCH_PPC 1 84 1.1 christos #include <urcu/arch/ppc.h> 85 1.1 christos 86 1.1 christos #elif (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) 87 1.1 christos 88 1.1 christos #define URCU_ARCH_S390 1 89 1.1 christos #include <urcu/arch/s390.h> 90 1.1 christos 91 1.1 christos #elif (defined(__sparc__) || defined(__sparc) || defined(__sparc64__)) 92 1.1 christos 93 1.1 christos #define URCU_ARCH_SPARC64 1 94 1.1 christos #include <urcu/arch/sparc64.h> 95 1.1 christos 96 1.1 christos #elif (defined(__alpha__) || defined(__alpha)) 97 1.1 christos 98 1.1 christos #define URCU_ARCH_ALPHA 1 99 1.1 christos #include <urcu/arch/alpha.h> 100 1.1 christos 101 1.1 christos #elif (defined(__ia64__) || defined(__ia64)) 102 1.1 christos 103 1.1 christos #define URCU_ARCH_IA64 1 104 1.1 christos #include <urcu/arch/ia64.h> 105 1.1 christos 106 1.1 christos #elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7__)) 107 1.1 christos 108 1.1 christos #define URCU_ARCH_ARMV7 1 109 1.1 christos #define URCU_ARCH_ARM 1 110 1.1 christos #include <urcu/arch/arm.h> 111 1.1 christos 112 1.1 christos #elif (defined(__arm__) || defined(__arm)) 113 1.1 christos 114 1.1 christos #define URCU_ARCH_ARM 1 115 1.1 christos #include <urcu/arch/arm.h> 116 1.1 christos 117 1.1 christos #elif defined(__aarch64__) 118 1.1 christos 119 1.1 christos #define URCU_ARCH_AARCH64 1 120 1.1 christos #include <urcu/arch/aarch64.h> 121 1.1 christos 122 1.1 christos #elif (defined(__mips__) || defined(__mips)) 123 1.1 christos 124 1.1 christos #define URCU_ARCH_MIPS 1 125 1.1 christos #include <urcu/arch/mips.h> 126 1.1 christos 127 1.1 christos #elif (defined(__nios2__) || defined(__nios2)) 128 1.1 christos 129 1.1 christos #define URCU_ARCH_NIOS2 1 130 1.1 christos #include <urcu/arch/nios2.h> 131 1.1 christos 132 1.1 christos #elif defined(__tilegx__) 133 1.1 christos /* 134 1.1 christos * URCU has only been tested on the TileGx architecture. For other Tile* 135 1.1 christos * architectures, please run the tests first and report the results to the 136 1.1 christos * maintainer so that proper support can be added. 137 1.1 christos */ 138 1.1 christos 139 1.1 christos #define URCU_ARCH_TILE 1 140 1.1 christos #include <urcu/arch/tile.h> 141 1.1 christos 142 1.1 christos #elif (defined(__hppa__) || defined(__HPPA__) || defined(__hppa)) 143 1.1 christos 144 1.1 christos #define URCU_ARCH_HPPA 1 145 1.1 christos #include <urcu/arch/hppa.h> 146 1.1 christos 147 1.1 christos #elif defined(__m68k__) 148 1.1 christos 149 1.1 christos #define URCU_ARCH_M68K 1 150 1.1 christos #include <urcu/arch/m68k.h> 151 1.1 christos 152 1.1 christos #elif defined(__riscv) 153 1.1 christos 154 1.1 christos #define URCU_ARCH_RISCV 1 155 1.1 christos #include <urcu/arch/riscv.h> 156 1.1 christos 157 1.1 christos #elif defined(__loongarch__) 158 1.1 christos 159 1.1 christos #define URCU_ARCH_LOONGARCH 1 160 1.1 christos #include <urcu/arch/loongarch.h> 161 1.1 christos 162 1.2 christos #elif defined(__vax__) 163 1.2 christos 164 1.2 christos #define URCU_ARCH_VAX 1 165 1.2 christos #include <urcu/arch/vax.h> 166 1.2 christos 167 1.2 christos #elif defined(__sh3__) 168 1.2 christos 169 1.2 christos #define URCU_ARCH_SH3 1 170 1.2 christos #include <urcu/arch/sh3.h> 171 1.2 christos 172 1.1 christos #else 173 1.2 christos 174 1.1 christos #error "Cannot build: unrecognized architecture, see <urcu/arch.h>." 175 1.1 christos #endif 176 1.1 christos 177 1.1 christos #ifdef CONFIG_RCU_EMIT_LEGACY_MB 178 1.1 christos # define cmm_emit_legacy_smp_mb() cmm_smp_mb() 179 1.1 christos #else 180 1.1 christos # define cmm_emit_legacy_smp_mb() do { } while (0) 181 1.1 christos #endif 182 1.1 christos 183 1.1 christos 184 1.1 christos #endif /* _URCU_ARCH_H */ 185