]>
| Commit | Line | Data |
|---|---|---|
| db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 099524d7 LP |
2 | #pragma once |
| 3 | ||
| 87fbd333 | 4 | #include <endian.h> |
| 6017365a | 5 | |
| 01e1303f | 6 | #include "forward.h" |
| 099524d7 | 7 | |
| 579af519 LP |
8 | /* A cleaned up architecture definition. We don't want to get lost in |
| 9 | * processor features, models, generations or even ABIs. Hence we | |
| 086df29f | 10 | * focus on general family, and distinguish word width and endianness. */ |
| 9a00f57a | 11 | |
| 4c701125 | 12 | typedef enum Architecture { |
| 099524d7 | 13 | ARCHITECTURE_ALPHA, |
| 086df29f ZJS |
14 | ARCHITECTURE_ARC, |
| 15 | ARCHITECTURE_ARC_BE, | |
| 099524d7 | 16 | ARCHITECTURE_ARM, |
| 099524d7 LP |
17 | ARCHITECTURE_ARM64, |
| 18 | ARCHITECTURE_ARM64_BE, | |
| 086df29f | 19 | ARCHITECTURE_ARM_BE, |
| 86bafac9 | 20 | ARCHITECTURE_CRIS, |
| 086df29f | 21 | ARCHITECTURE_IA64, |
| 5c0968a2 | 22 | ARCHITECTURE_LOONGARCH64, |
| 086df29f ZJS |
23 | ARCHITECTURE_M68K, |
| 24 | ARCHITECTURE_MIPS, | |
| 25 | ARCHITECTURE_MIPS64, | |
| 26 | ARCHITECTURE_MIPS64_LE, | |
| 27 | ARCHITECTURE_MIPS_LE, | |
| b79660e6 | 28 | ARCHITECTURE_NIOS2, |
| 086df29f ZJS |
29 | ARCHITECTURE_PARISC, |
| 30 | ARCHITECTURE_PARISC64, | |
| 31 | ARCHITECTURE_PPC, | |
| 32 | ARCHITECTURE_PPC64, | |
| 33 | ARCHITECTURE_PPC64_LE, | |
| 34 | ARCHITECTURE_PPC_LE, | |
| 171b5338 RJ |
35 | ARCHITECTURE_RISCV32, |
| 36 | ARCHITECTURE_RISCV64, | |
| 086df29f ZJS |
37 | ARCHITECTURE_S390, |
| 38 | ARCHITECTURE_S390X, | |
| 39 | ARCHITECTURE_SH, | |
| 40 | ARCHITECTURE_SH64, | |
| 41 | ARCHITECTURE_SPARC, | |
| 42 | ARCHITECTURE_SPARC64, | |
| 43 | ARCHITECTURE_TILEGX, | |
| 44 | ARCHITECTURE_X86, | |
| 45 | ARCHITECTURE_X86_64, | |
| 099524d7 | 46 | _ARCHITECTURE_MAX, |
| 2d93c20e | 47 | _ARCHITECTURE_INVALID = -EINVAL, |
| b998ff21 | 48 | } Architecture; |
| 099524d7 | 49 | |
| 6b41a7b2 | 50 | Architecture uname_architecture(void); |
| 099524d7 | 51 | |
| 9a00f57a | 52 | /* |
| 613e3a26 LP |
53 | * LIB_ARCH_TUPLE should resolve to the local library path |
| 54 | * architecture tuple systemd is built for, according to the Debian | |
| 55 | * tuple list: | |
| 9a00f57a LP |
56 | * |
| 57 | * https://wiki.debian.org/Multiarch/Tuples | |
| 58 | * | |
| 613e3a26 LP |
59 | * This is used in library search paths that should understand |
| 60 | * Debian's paths on all distributions. | |
| 9a00f57a LP |
61 | */ |
| 62 | ||
| 099524d7 LP |
63 | #if defined(__x86_64__) |
| 64 | # define native_architecture() ARCHITECTURE_X86_64 | |
| 4c7c70c7 JPAG |
65 | # if defined(__ILP32__) |
| 66 | # define LIB_ARCH_TUPLE "x86_64-linux-gnux32" | |
| 67 | # else | |
| 68 | # define LIB_ARCH_TUPLE "x86_64-linux-gnu" | |
| 69 | # endif | |
| 3c58ae13 | 70 | # define ARCHITECTURE_SECONDARY ARCHITECTURE_X86 |
| 099524d7 LP |
71 | #elif defined(__i386__) |
| 72 | # define native_architecture() ARCHITECTURE_X86 | |
| 613e3a26 | 73 | # define LIB_ARCH_TUPLE "i386-linux-gnu" |
| 099524d7 | 74 | #elif defined(__powerpc64__) |
| 4f4b92ba | 75 | # if __BYTE_ORDER == __BIG_ENDIAN |
| ae0e60fb | 76 | # define native_architecture() ARCHITECTURE_PPC64 |
| 613e3a26 | 77 | # define LIB_ARCH_TUPLE "ppc64-linux-gnu" |
| 3c58ae13 | 78 | # define ARCHITECTURE_SECONDARY ARCHITECTURE_PPC |
| ae0e60fb LP |
79 | # else |
| 80 | # define native_architecture() ARCHITECTURE_PPC64_LE | |
| 37d6781b | 81 | # define LIB_ARCH_TUPLE "powerpc64le-linux-gnu" |
| 3c58ae13 | 82 | # define ARCHITECTURE_SECONDARY ARCHITECTURE_PPC_LE |
| ae0e60fb | 83 | # endif |
| 099524d7 | 84 | #elif defined(__powerpc__) |
| 4f4b92ba | 85 | # if __BYTE_ORDER == __BIG_ENDIAN |
| ae0e60fb | 86 | # define native_architecture() ARCHITECTURE_PPC |
| 202145c0 JPAG |
87 | # if defined(__NO_FPRS__) |
| 88 | # define LIB_ARCH_TUPLE "powerpc-linux-gnuspe" | |
| 89 | # else | |
| 90 | # define LIB_ARCH_TUPLE "powerpc-linux-gnu" | |
| 91 | # endif | |
| ae0e60fb LP |
92 | # else |
| 93 | # define native_architecture() ARCHITECTURE_PPC_LE | |
| 613e3a26 | 94 | # error "Missing LIB_ARCH_TUPLE for PPCLE" |
| ae0e60fb | 95 | # endif |
| 099524d7 LP |
96 | #elif defined(__ia64__) |
| 97 | # define native_architecture() ARCHITECTURE_IA64 | |
| 613e3a26 | 98 | # define LIB_ARCH_TUPLE "ia64-linux-gnu" |
| 099524d7 LP |
99 | #elif defined(__hppa64__) |
| 100 | # define native_architecture() ARCHITECTURE_PARISC64 | |
| 613e3a26 | 101 | # error "Missing LIB_ARCH_TUPLE for HPPA64" |
| 099524d7 LP |
102 | #elif defined(__hppa__) |
| 103 | # define native_architecture() ARCHITECTURE_PARISC | |
| 613e3a26 | 104 | # define LIB_ARCH_TUPLE "hppa‑linux‑gnu" |
| 099524d7 LP |
105 | #elif defined(__s390x__) |
| 106 | # define native_architecture() ARCHITECTURE_S390X | |
| 613e3a26 | 107 | # define LIB_ARCH_TUPLE "s390x-linux-gnu" |
| 3c58ae13 | 108 | # define ARCHITECTURE_SECONDARY ARCHITECTURE_S390 |
| 099524d7 LP |
109 | #elif defined(__s390__) |
| 110 | # define native_architecture() ARCHITECTURE_S390 | |
| 613e3a26 | 111 | # define LIB_ARCH_TUPLE "s390-linux-gnu" |
| cd042078 | 112 | #elif defined(__sparc__) && defined (__arch64__) |
| 099524d7 | 113 | # define native_architecture() ARCHITECTURE_SPARC64 |
| 613e3a26 | 114 | # define LIB_ARCH_TUPLE "sparc64-linux-gnu" |
| 099524d7 LP |
115 | #elif defined(__sparc__) |
| 116 | # define native_architecture() ARCHITECTURE_SPARC | |
| 613e3a26 | 117 | # define LIB_ARCH_TUPLE "sparc-linux-gnu" |
| caf49b95 | 118 | #elif defined(__mips64) && defined(__LP64__) |
| 4f4b92ba | 119 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 9a00f57a | 120 | # define native_architecture() ARCHITECTURE_MIPS64 |
| caf49b95 | 121 | # define LIB_ARCH_TUPLE "mips64-linux-gnuabi64" |
| 9a00f57a LP |
122 | # else |
| 123 | # define native_architecture() ARCHITECTURE_MIPS64_LE | |
| caf49b95 YS |
124 | # define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64" |
| 125 | # endif | |
| 126 | #elif defined(__mips64) | |
| 127 | # if __BYTE_ORDER == __BIG_ENDIAN | |
| 128 | # define native_architecture() ARCHITECTURE_MIPS64 | |
| 129 | # define LIB_ARCH_TUPLE "mips64-linux-gnuabin32" | |
| 130 | # else | |
| 131 | # define native_architecture() ARCHITECTURE_MIPS64_LE | |
| 132 | # define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32" | |
| 9a00f57a | 133 | # endif |
| 099524d7 | 134 | #elif defined(__mips__) |
| 4f4b92ba | 135 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 9a00f57a | 136 | # define native_architecture() ARCHITECTURE_MIPS |
| 613e3a26 | 137 | # define LIB_ARCH_TUPLE "mips-linux-gnu" |
| 9a00f57a LP |
138 | # else |
| 139 | # define native_architecture() ARCHITECTURE_MIPS_LE | |
| 613e3a26 | 140 | # define LIB_ARCH_TUPLE "mipsel-linux-gnu" |
| 568981d2 | 141 | # endif |
| 099524d7 LP |
142 | #elif defined(__alpha__) |
| 143 | # define native_architecture() ARCHITECTURE_ALPHA | |
| 613e3a26 | 144 | # define LIB_ARCH_TUPLE "alpha-linux-gnu" |
| 099524d7 | 145 | #elif defined(__aarch64__) |
| 4f4b92ba | 146 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 099524d7 | 147 | # define native_architecture() ARCHITECTURE_ARM64_BE |
| 613e3a26 | 148 | # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu" |
| 099524d7 LP |
149 | # else |
| 150 | # define native_architecture() ARCHITECTURE_ARM64 | |
| 613e3a26 | 151 | # define LIB_ARCH_TUPLE "aarch64-linux-gnu" |
| 3c58ae13 | 152 | # define ARCHITECTURE_SECONDARY ARCHITECTURE_ARM |
| 099524d7 LP |
153 | # endif |
| 154 | #elif defined(__arm__) | |
| 4f4b92ba | 155 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 099524d7 | 156 | # define native_architecture() ARCHITECTURE_ARM_BE |
| 579af519 LP |
157 | # if defined(__ARM_EABI__) |
| 158 | # if defined(__ARM_PCS_VFP) | |
| 159 | # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf" | |
| 160 | # else | |
| 161 | # define LIB_ARCH_TUPLE "armeb-linux-gnueabi" | |
| 162 | # endif | |
| 0881d7af | 163 | # else |
| 579af519 | 164 | # define LIB_ARCH_TUPLE "armeb-linux-gnu" |
| 0881d7af | 165 | # endif |
| 099524d7 | 166 | # else |
| 0881d7af | 167 | # define native_architecture() ARCHITECTURE_ARM |
| 2a9899d8 ZJS |
168 | # if defined(__ARM_EABI__) |
| 169 | # if defined(__ARM_PCS_VFP) | |
| 170 | # define LIB_ARCH_TUPLE "arm-linux-gnueabihf" | |
| 171 | # else | |
| 172 | # define LIB_ARCH_TUPLE "arm-linux-gnueabi" | |
| 173 | # endif | |
| fd3b401e | 174 | # else |
| 2a9899d8 | 175 | # define LIB_ARCH_TUPLE "arm-linux-gnu" |
| fd3b401e | 176 | # endif |
| 099524d7 LP |
177 | # endif |
| 178 | #elif defined(__sh64__) | |
| 179 | # define native_architecture() ARCHITECTURE_SH64 | |
| 613e3a26 | 180 | # error "Missing LIB_ARCH_TUPLE for SH64" |
| 099524d7 LP |
181 | #elif defined(__sh__) |
| 182 | # define native_architecture() ARCHITECTURE_SH | |
| 9da2a0ac JPAG |
183 | # if defined(__SH1__) |
| 184 | # define LIB_ARCH_TUPLE "sh1-linux-gnu" | |
| 185 | # elif defined(__SH2__) | |
| 186 | # define LIB_ARCH_TUPLE "sh2-linux-gnu" | |
| 187 | # elif defined(__SH2A__) | |
| 188 | # define LIB_ARCH_TUPLE "sh2a-linux-gnu" | |
| 189 | # elif defined(__SH2E__) | |
| 190 | # define LIB_ARCH_TUPLE "sh2e-linux-gnu" | |
| 191 | # elif defined(__SH3__) | |
| 192 | # define LIB_ARCH_TUPLE "sh3-linux-gnu" | |
| 193 | # elif defined(__SH3E__) | |
| 194 | # define LIB_ARCH_TUPLE "sh3e-linux-gnu" | |
| 195 | # elif defined(__SH4__) && !defined(__SH4A__) | |
| 196 | # define LIB_ARCH_TUPLE "sh4-linux-gnu" | |
| 197 | # elif defined(__SH4A__) | |
| 198 | # define LIB_ARCH_TUPLE "sh4a-linux-gnu" | |
| 199 | # endif | |
| a4a2077d | 200 | #elif defined(__loongarch_lp64) |
| 01722893 XW |
201 | # define native_architecture() ARCHITECTURE_LOONGARCH64 |
| 202 | # if defined(__loongarch_double_float) | |
| a4a2077d | 203 | # define LIB_ARCH_TUPLE "loongarch64-linux-gnu" |
| 01722893 XW |
204 | # elif defined(__loongarch_single_float) |
| 205 | # define LIB_ARCH_TUPLE "loongarch64-linux-gnuf32" | |
| 206 | # elif defined(__loongarch_soft_float) | |
| 207 | # define LIB_ARCH_TUPLE "loongarch64-linux-gnusf" | |
| 208 | # else | |
| 209 | # error "Unrecognized loongarch architecture variant" | |
| 210 | # endif | |
| 099524d7 LP |
211 | #elif defined(__m68k__) |
| 212 | # define native_architecture() ARCHITECTURE_M68K | |
| 613e3a26 | 213 | # define LIB_ARCH_TUPLE "m68k-linux-gnu" |
| 46eea341 HGB |
214 | #elif defined(__tilegx__) |
| 215 | # define native_architecture() ARCHITECTURE_TILEGX | |
| b1caafb2 | 216 | # define LIB_ARCH_TUPLE "tilegx-linux-gnu" |
| 86bafac9 UTL |
217 | #elif defined(__cris__) |
| 218 | # define native_architecture() ARCHITECTURE_CRIS | |
| 613e3a26 | 219 | # error "Missing LIB_ARCH_TUPLE for CRIS" |
| b79660e6 ZJS |
220 | #elif defined(__nios2__) |
| 221 | # define native_architecture() ARCHITECTURE_NIOS2 | |
| 222 | # define LIB_ARCH_TUPLE "nios2-linux-gnu" | |
| 3299c293 | 223 | #elif defined(__riscv) |
| 171b5338 RJ |
224 | # if __SIZEOF_POINTER__ == 4 |
| 225 | # define native_architecture() ARCHITECTURE_RISCV32 | |
| 226 | # define LIB_ARCH_TUPLE "riscv32-linux-gnu" | |
| 227 | # elif __SIZEOF_POINTER__ == 8 | |
| 228 | # define native_architecture() ARCHITECTURE_RISCV64 | |
| 229 | # define LIB_ARCH_TUPLE "riscv64-linux-gnu" | |
| 230 | # else | |
| 231 | # error "Unrecognized riscv architecture variant" | |
| 232 | # endif | |
| 27b09f1f AB |
233 | #elif defined(__arc__) |
| 234 | # if __BYTE_ORDER == __BIG_ENDIAN | |
| 235 | # define native_architecture() ARCHITECTURE_ARC_BE | |
| 236 | # define LIB_ARCH_TUPLE "arceb-linux" | |
| 237 | # else | |
| 238 | # define native_architecture() ARCHITECTURE_ARC | |
| 239 | # define LIB_ARCH_TUPLE "arc-linux" | |
| 240 | # endif | |
| 099524d7 | 241 | #else |
| 568981d2 | 242 | # error "Please register your architecture here!" |
| 099524d7 LP |
243 | #endif |
| 244 | ||
| 8533513a DDM |
245 | #if defined(__hppa__) || defined(__hppa64__) |
| 246 | # define STACK_GROWS_UP 1 | |
| 247 | #else | |
| 248 | # define STACK_GROWS_UP 0 | |
| 249 | #endif | |
| 250 | ||
| aec52c1e | 251 | DECLARE_STRING_TABLE_LOOKUP(architecture, Architecture); |