]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/architecture.h
4 This file is part of systemd.
6 Copyright 2014 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 /* A cleaned up architecture definition. We don't want to get lost in
28 * processor features, models, generations or even ABIs. Hence we
29 * focus on general family, and distinguish word width and
38 ARCHITECTURE_PPC64_LE
,
41 ARCHITECTURE_PARISC64
,
49 ARCHITECTURE_MIPS64_LE
,
54 ARCHITECTURE_ARM64_BE
,
66 _ARCHITECTURE_INVALID
= -1
69 int uname_architecture(void);
72 * LIB_ARCH_TUPLE should resolve to the local library path
73 * architecture tuple systemd is built for, according to the Debian
76 * https://wiki.debian.org/Multiarch/Tuples
78 * This is used in library search paths that should understand
79 * Debian's paths on all distributions.
82 #if defined(__x86_64__)
83 # define native_architecture() ARCHITECTURE_X86_64
84 # if defined(__ILP32__)
85 # define LIB_ARCH_TUPLE "x86_64-linux-gnux32"
87 # define LIB_ARCH_TUPLE "x86_64-linux-gnu"
89 # define SECONDARY_ARCHITECTURE ARCHITECTURE_X86
90 #elif defined(__i386__)
91 # define native_architecture() ARCHITECTURE_X86
92 # define LIB_ARCH_TUPLE "i386-linux-gnu"
93 #elif defined(__powerpc64__)
94 # if __BYTE_ORDER == __BIG_ENDIAN
95 # define native_architecture() ARCHITECTURE_PPC64
96 # define LIB_ARCH_TUPLE "ppc64-linux-gnu"
97 # define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC
99 # define native_architecture() ARCHITECTURE_PPC64_LE
100 # define LIB_ARCH_TUPLE "powerpc64le-linux-gnu"
101 # define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC_LE
103 #elif defined(__powerpc__)
104 # if __BYTE_ORDER == __BIG_ENDIAN
105 # define native_architecture() ARCHITECTURE_PPC
106 # if defined(__NO_FPRS__)
107 # define LIB_ARCH_TUPLE "powerpc-linux-gnuspe"
109 # define LIB_ARCH_TUPLE "powerpc-linux-gnu"
112 # define native_architecture() ARCHITECTURE_PPC_LE
113 # error "Missing LIB_ARCH_TUPLE for PPCLE"
115 #elif defined(__ia64__)
116 # define native_architecture() ARCHITECTURE_IA64
117 # define LIB_ARCH_TUPLE "ia64-linux-gnu"
118 #elif defined(__hppa64__)
119 # define native_architecture() ARCHITECTURE_PARISC64
120 # error "Missing LIB_ARCH_TUPLE for HPPA64"
121 #elif defined(__hppa__)
122 # define native_architecture() ARCHITECTURE_PARISC
123 # define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
124 #elif defined(__s390x__)
125 # define native_architecture() ARCHITECTURE_S390X
126 # define LIB_ARCH_TUPLE "s390x-linux-gnu"
127 # define SECONDARY_ARCHITECTURE ARCHITECTURE_S390
128 #elif defined(__s390__)
129 # define native_architecture() ARCHITECTURE_S390
130 # define LIB_ARCH_TUPLE "s390-linux-gnu"
131 #elif defined(__sparc__) && defined (__arch64__)
132 # define native_architecture() ARCHITECTURE_SPARC64
133 # define LIB_ARCH_TUPLE "sparc64-linux-gnu"
134 #elif defined(__sparc__)
135 # define native_architecture() ARCHITECTURE_SPARC
136 # define LIB_ARCH_TUPLE "sparc-linux-gnu"
137 #elif defined(__mips64) && defined(__LP64__)
138 # if __BYTE_ORDER == __BIG_ENDIAN
139 # define native_architecture() ARCHITECTURE_MIPS64
140 # define LIB_ARCH_TUPLE "mips64-linux-gnuabi64"
142 # define native_architecture() ARCHITECTURE_MIPS64_LE
143 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64"
145 #elif defined(__mips64)
146 # if __BYTE_ORDER == __BIG_ENDIAN
147 # define native_architecture() ARCHITECTURE_MIPS64
148 # define LIB_ARCH_TUPLE "mips64-linux-gnuabin32"
150 # define native_architecture() ARCHITECTURE_MIPS64_LE
151 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32"
153 #elif defined(__mips__)
154 # if __BYTE_ORDER == __BIG_ENDIAN
155 # define native_architecture() ARCHITECTURE_MIPS
156 # define LIB_ARCH_TUPLE "mips-linux-gnu"
158 # define native_architecture() ARCHITECTURE_MIPS_LE
159 # define LIB_ARCH_TUPLE "mipsel-linux-gnu"
161 #elif defined(__alpha__)
162 # define native_architecture() ARCHITECTURE_ALPHA
163 # define LIB_ARCH_TUPLE "alpha-linux-gnu"
164 #elif defined(__aarch64__)
165 # if __BYTE_ORDER == __BIG_ENDIAN
166 # define native_architecture() ARCHITECTURE_ARM64_BE
167 # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
169 # define native_architecture() ARCHITECTURE_ARM64
170 # define LIB_ARCH_TUPLE "aarch64-linux-gnu"
171 # define SECONDARY_ARCHITECTURE ARCHITECTURE_ARM
173 #elif defined(__arm__)
174 # if __BYTE_ORDER == __BIG_ENDIAN
175 # define native_architecture() ARCHITECTURE_ARM_BE
176 # if defined(__ARM_EABI__)
177 # if defined(__ARM_PCS_VFP)
178 # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
180 # define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
183 # define LIB_ARCH_TUPLE "armeb-linux-gnu"
186 # define native_architecture() ARCHITECTURE_ARM
187 # if defined(__ARM_EABI__)
188 # if defined(__ARM_PCS_VFP)
189 # define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
191 # define LIB_ARCH_TUPLE "arm-linux-gnueabi"
194 # define LIB_ARCH_TUPLE "arm-linux-gnu"
197 #elif defined(__sh64__)
198 # define native_architecture() ARCHITECTURE_SH64
199 # error "Missing LIB_ARCH_TUPLE for SH64"
200 #elif defined(__sh__)
201 # define native_architecture() ARCHITECTURE_SH
202 # if defined(__SH1__)
203 # define LIB_ARCH_TUPLE "sh1-linux-gnu"
204 # elif defined(__SH2__)
205 # define LIB_ARCH_TUPLE "sh2-linux-gnu"
206 # elif defined(__SH2A__)
207 # define LIB_ARCH_TUPLE "sh2a-linux-gnu"
208 # elif defined(__SH2E__)
209 # define LIB_ARCH_TUPLE "sh2e-linux-gnu"
210 # elif defined(__SH3__)
211 # define LIB_ARCH_TUPLE "sh3-linux-gnu"
212 # elif defined(__SH3E__)
213 # define LIB_ARCH_TUPLE "sh3e-linux-gnu"
214 # elif defined(__SH4__) && !defined(__SH4A__)
215 # define LIB_ARCH_TUPLE "sh4-linux-gnu"
216 # elif defined(__SH4A__)
217 # define LIB_ARCH_TUPLE "sh4a-linux-gnu"
219 #elif defined(__m68k__)
220 # define native_architecture() ARCHITECTURE_M68K
221 # define LIB_ARCH_TUPLE "m68k-linux-gnu"
222 #elif defined(__tilegx__)
223 # define native_architecture() ARCHITECTURE_TILEGX
224 # define LIB_ARCH_TUPLE "tilegx-linux-gnu"
225 #elif defined(__cris__)
226 # define native_architecture() ARCHITECTURE_CRIS
227 # error "Missing LIB_ARCH_TUPLE for CRIS"
228 #elif defined(__nios2__)
229 # define native_architecture() ARCHITECTURE_NIOS2
230 # define LIB_ARCH_TUPLE "nios2-linux-gnu"
231 #elif defined(__riscv__) || defined(__riscv)
232 /* __riscv__ is obsolete, remove in 2018 */
233 # if __SIZEOF_POINTER__ == 4
234 # define native_architecture() ARCHITECTURE_RISCV32
235 # define LIB_ARCH_TUPLE "riscv32-linux-gnu"
236 # elif __SIZEOF_POINTER__ == 8
237 # define native_architecture() ARCHITECTURE_RISCV64
238 # define LIB_ARCH_TUPLE "riscv64-linux-gnu"
240 # error "Unrecognized riscv architecture variant"
242 #elif defined(__arc__)
243 # if __BYTE_ORDER == __BIG_ENDIAN
244 # define native_architecture() ARCHITECTURE_ARC_BE
245 # define LIB_ARCH_TUPLE "arceb-linux"
247 # define native_architecture() ARCHITECTURE_ARC
248 # define LIB_ARCH_TUPLE "arc-linux"
251 # error "Please register your architecture here!"
254 const char *architecture_to_string(int a
) _const_
;
255 int architecture_from_string(const char *s
) _pure_
;