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