]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/architecture.h
3793415e5d8a91a380f52cfd85d6f9bd7bd81fb4
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include <endian.h> /* IWYU pragma: keep */
8 /* A cleaned up architecture definition. We don't want to get lost in
9 * processor features, models, generations or even ABIs. Hence we
10 * focus on general family, and distinguish word width and endianness. */
18 ARCHITECTURE_ARM64_BE
,
22 ARCHITECTURE_LOONGARCH64
,
26 ARCHITECTURE_MIPS64_LE
,
30 ARCHITECTURE_PARISC64
,
33 ARCHITECTURE_PPC64_LE
,
47 _ARCHITECTURE_INVALID
= -EINVAL
,
50 Architecture
uname_architecture(void);
53 * LIB_ARCH_TUPLE should resolve to the local library path
54 * architecture tuple systemd is built for, according to the Debian
57 * https://wiki.debian.org/Multiarch/Tuples
59 * This is used in library search paths that should understand
60 * Debian's paths on all distributions.
63 #if defined(__x86_64__)
64 # define native_architecture() ARCHITECTURE_X86_64
65 # if defined(__ILP32__)
66 # define LIB_ARCH_TUPLE "x86_64-linux-gnux32"
68 # define LIB_ARCH_TUPLE "x86_64-linux-gnu"
70 # define ARCHITECTURE_SECONDARY ARCHITECTURE_X86
71 #elif defined(__i386__)
72 # define native_architecture() ARCHITECTURE_X86
73 # define LIB_ARCH_TUPLE "i386-linux-gnu"
74 #elif defined(__powerpc64__)
75 # if __BYTE_ORDER == __BIG_ENDIAN
76 # define native_architecture() ARCHITECTURE_PPC64
77 # define LIB_ARCH_TUPLE "ppc64-linux-gnu"
78 # define ARCHITECTURE_SECONDARY ARCHITECTURE_PPC
80 # define native_architecture() ARCHITECTURE_PPC64_LE
81 # define LIB_ARCH_TUPLE "powerpc64le-linux-gnu"
82 # define ARCHITECTURE_SECONDARY ARCHITECTURE_PPC_LE
84 #elif defined(__powerpc__)
85 # if __BYTE_ORDER == __BIG_ENDIAN
86 # define native_architecture() ARCHITECTURE_PPC
87 # if defined(__NO_FPRS__)
88 # define LIB_ARCH_TUPLE "powerpc-linux-gnuspe"
90 # define LIB_ARCH_TUPLE "powerpc-linux-gnu"
93 # define native_architecture() ARCHITECTURE_PPC_LE
94 # error "Missing LIB_ARCH_TUPLE for PPCLE"
96 #elif defined(__ia64__)
97 # define native_architecture() ARCHITECTURE_IA64
98 # define LIB_ARCH_TUPLE "ia64-linux-gnu"
99 #elif defined(__hppa64__)
100 # define native_architecture() ARCHITECTURE_PARISC64
101 # error "Missing LIB_ARCH_TUPLE for HPPA64"
102 #elif defined(__hppa__)
103 # define native_architecture() ARCHITECTURE_PARISC
104 # define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
105 #elif defined(__s390x__)
106 # define native_architecture() ARCHITECTURE_S390X
107 # define LIB_ARCH_TUPLE "s390x-linux-gnu"
108 # define ARCHITECTURE_SECONDARY ARCHITECTURE_S390
109 #elif defined(__s390__)
110 # define native_architecture() ARCHITECTURE_S390
111 # define LIB_ARCH_TUPLE "s390-linux-gnu"
112 #elif defined(__sparc__) && defined (__arch64__)
113 # define native_architecture() ARCHITECTURE_SPARC64
114 # define LIB_ARCH_TUPLE "sparc64-linux-gnu"
115 #elif defined(__sparc__)
116 # define native_architecture() ARCHITECTURE_SPARC
117 # define LIB_ARCH_TUPLE "sparc-linux-gnu"
118 #elif defined(__mips64) && defined(__LP64__)
119 # if __BYTE_ORDER == __BIG_ENDIAN
120 # define native_architecture() ARCHITECTURE_MIPS64
121 # define LIB_ARCH_TUPLE "mips64-linux-gnuabi64"
123 # define native_architecture() ARCHITECTURE_MIPS64_LE
124 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64"
126 #elif defined(__mips64)
127 # if __BYTE_ORDER == __BIG_ENDIAN
128 # define native_architecture() ARCHITECTURE_MIPS64
129 # define LIB_ARCH_TUPLE "mips64-linux-gnuabin32"
131 # define native_architecture() ARCHITECTURE_MIPS64_LE
132 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32"
134 #elif defined(__mips__)
135 # if __BYTE_ORDER == __BIG_ENDIAN
136 # define native_architecture() ARCHITECTURE_MIPS
137 # define LIB_ARCH_TUPLE "mips-linux-gnu"
139 # define native_architecture() ARCHITECTURE_MIPS_LE
140 # define LIB_ARCH_TUPLE "mipsel-linux-gnu"
142 #elif defined(__alpha__)
143 # define native_architecture() ARCHITECTURE_ALPHA
144 # define LIB_ARCH_TUPLE "alpha-linux-gnu"
145 #elif defined(__aarch64__)
146 # if __BYTE_ORDER == __BIG_ENDIAN
147 # define native_architecture() ARCHITECTURE_ARM64_BE
148 # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
150 # define native_architecture() ARCHITECTURE_ARM64
151 # define LIB_ARCH_TUPLE "aarch64-linux-gnu"
152 # define ARCHITECTURE_SECONDARY ARCHITECTURE_ARM
154 #elif defined(__arm__)
155 # if __BYTE_ORDER == __BIG_ENDIAN
156 # define native_architecture() ARCHITECTURE_ARM_BE
157 # if defined(__ARM_EABI__)
158 # if defined(__ARM_PCS_VFP)
159 # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
161 # define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
164 # define LIB_ARCH_TUPLE "armeb-linux-gnu"
167 # define native_architecture() ARCHITECTURE_ARM
168 # if defined(__ARM_EABI__)
169 # if defined(__ARM_PCS_VFP)
170 # define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
172 # define LIB_ARCH_TUPLE "arm-linux-gnueabi"
175 # define LIB_ARCH_TUPLE "arm-linux-gnu"
178 #elif defined(__sh64__)
179 # define native_architecture() ARCHITECTURE_SH64
180 # error "Missing LIB_ARCH_TUPLE for SH64"
181 #elif defined(__sh__)
182 # define native_architecture() ARCHITECTURE_SH
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"
200 #elif defined(__loongarch_lp64)
201 # define native_architecture() ARCHITECTURE_LOONGARCH64
202 # if defined(__loongarch_double_float)
203 # define LIB_ARCH_TUPLE "loongarch64-linux-gnu"
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"
209 # error "Unrecognized loongarch architecture variant"
211 #elif defined(__m68k__)
212 # define native_architecture() ARCHITECTURE_M68K
213 # define LIB_ARCH_TUPLE "m68k-linux-gnu"
214 #elif defined(__tilegx__)
215 # define native_architecture() ARCHITECTURE_TILEGX
216 # define LIB_ARCH_TUPLE "tilegx-linux-gnu"
217 #elif defined(__cris__)
218 # define native_architecture() ARCHITECTURE_CRIS
219 # error "Missing LIB_ARCH_TUPLE for CRIS"
220 #elif defined(__nios2__)
221 # define native_architecture() ARCHITECTURE_NIOS2
222 # define LIB_ARCH_TUPLE "nios2-linux-gnu"
223 #elif defined(__riscv)
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"
231 # error "Unrecognized riscv architecture variant"
233 #elif defined(__arc__)
234 # if __BYTE_ORDER == __BIG_ENDIAN
235 # define native_architecture() ARCHITECTURE_ARC_BE
236 # define LIB_ARCH_TUPLE "arceb-linux"
238 # define native_architecture() ARCHITECTURE_ARC
239 # define LIB_ARCH_TUPLE "arc-linux"
242 # error "Please register your architecture here!"
245 const char* architecture_to_string(Architecture a
) _const_
;
246 Architecture
architecture_from_string(const char *s
) _pure_
;