]>
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
,
64 _ARCHITECTURE_INVALID
= -1
67 int uname_architecture(void);
70 * LIB_ARCH_TUPLE should resolve to the local library path
71 * architecture tuple systemd is built for, according to the Debian
74 * https://wiki.debian.org/Multiarch/Tuples
76 * This is used in library search paths that should understand
77 * Debian's paths on all distributions.
80 #if defined(__x86_64__)
81 # define native_architecture() ARCHITECTURE_X86_64
82 # if defined(__ILP32__)
83 # define LIB_ARCH_TUPLE "x86_64-linux-gnux32"
85 # define LIB_ARCH_TUPLE "x86_64-linux-gnu"
87 # define SECONDARY_ARCHITECTURE ARCHITECTURE_X86
88 #elif defined(__i386__)
89 # define native_architecture() ARCHITECTURE_X86
90 # define LIB_ARCH_TUPLE "i386-linux-gnu"
91 #elif defined(__powerpc64__)
92 # if __BYTE_ORDER == __BIG_ENDIAN
93 # define native_architecture() ARCHITECTURE_PPC64
94 # define LIB_ARCH_TUPLE "ppc64-linux-gnu"
95 # define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC
97 # define native_architecture() ARCHITECTURE_PPC64_LE
98 # define LIB_ARCH_TUPLE "powerpc64le-linux-gnu"
99 # define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC_LE
101 #elif defined(__powerpc__)
102 # if __BYTE_ORDER == __BIG_ENDIAN
103 # define native_architecture() ARCHITECTURE_PPC
104 # if defined(__NO_FPRS__)
105 # define LIB_ARCH_TUPLE "powerpc-linux-gnuspe"
107 # define LIB_ARCH_TUPLE "powerpc-linux-gnu"
110 # define native_architecture() ARCHITECTURE_PPC_LE
111 # error "Missing LIB_ARCH_TUPLE for PPCLE"
113 #elif defined(__ia64__)
114 # define native_architecture() ARCHITECTURE_IA64
115 # define LIB_ARCH_TUPLE "ia64-linux-gnu"
116 #elif defined(__hppa64__)
117 # define native_architecture() ARCHITECTURE_PARISC64
118 # error "Missing LIB_ARCH_TUPLE for HPPA64"
119 #elif defined(__hppa__)
120 # define native_architecture() ARCHITECTURE_PARISC
121 # define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
122 #elif defined(__s390x__)
123 # define native_architecture() ARCHITECTURE_S390X
124 # define LIB_ARCH_TUPLE "s390x-linux-gnu"
125 # define SECONDARY_ARCHITECTURE ARCHITECTURE_S390
126 #elif defined(__s390__)
127 # define native_architecture() ARCHITECTURE_S390
128 # define LIB_ARCH_TUPLE "s390-linux-gnu"
129 #elif defined(__sparc__) && defined (__arch64__)
130 # define native_architecture() ARCHITECTURE_SPARC64
131 # define LIB_ARCH_TUPLE "sparc64-linux-gnu"
132 #elif defined(__sparc__)
133 # define native_architecture() ARCHITECTURE_SPARC
134 # define LIB_ARCH_TUPLE "sparc-linux-gnu"
135 #elif defined(__mips64) && defined(__LP64__)
136 # if __BYTE_ORDER == __BIG_ENDIAN
137 # define native_architecture() ARCHITECTURE_MIPS64
138 # define LIB_ARCH_TUPLE "mips64-linux-gnuabi64"
140 # define native_architecture() ARCHITECTURE_MIPS64_LE
141 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64"
143 #elif defined(__mips64)
144 # if __BYTE_ORDER == __BIG_ENDIAN
145 # define native_architecture() ARCHITECTURE_MIPS64
146 # define LIB_ARCH_TUPLE "mips64-linux-gnuabin32"
148 # define native_architecture() ARCHITECTURE_MIPS64_LE
149 # define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32"
151 #elif defined(__mips__)
152 # if __BYTE_ORDER == __BIG_ENDIAN
153 # define native_architecture() ARCHITECTURE_MIPS
154 # define LIB_ARCH_TUPLE "mips-linux-gnu"
156 # define native_architecture() ARCHITECTURE_MIPS_LE
157 # define LIB_ARCH_TUPLE "mipsel-linux-gnu"
159 #elif defined(__alpha__)
160 # define native_architecture() ARCHITECTURE_ALPHA
161 # define LIB_ARCH_TUPLE "alpha-linux-gnu"
162 #elif defined(__aarch64__)
163 # if __BYTE_ORDER == __BIG_ENDIAN
164 # define native_architecture() ARCHITECTURE_ARM64_BE
165 # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
167 # define native_architecture() ARCHITECTURE_ARM64
168 # define LIB_ARCH_TUPLE "aarch64-linux-gnu"
169 # define SECONDARY_ARCHITECTURE ARCHITECTURE_ARM
171 #elif defined(__arm__)
172 # if __BYTE_ORDER == __BIG_ENDIAN
173 # define native_architecture() ARCHITECTURE_ARM_BE
174 # if defined(__ARM_EABI__)
175 # if defined(__ARM_PCS_VFP)
176 # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
178 # define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
181 # define LIB_ARCH_TUPLE "armeb-linux-gnu"
184 # define native_architecture() ARCHITECTURE_ARM
185 # if defined(__ARM_EABI__)
186 # if defined(__ARM_PCS_VFP)
187 # define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
189 # define LIB_ARCH_TUPLE "arm-linux-gnueabi"
192 # define LIB_ARCH_TUPLE "arm-linux-gnu"
195 #elif defined(__sh64__)
196 # define native_architecture() ARCHITECTURE_SH64
197 # error "Missing LIB_ARCH_TUPLE for SH64"
198 #elif defined(__sh__)
199 # define native_architecture() ARCHITECTURE_SH
200 # define LIB_ARCH_TUPLE "sh4-linux-gnu"
201 #elif defined(__m68k__)
202 # define native_architecture() ARCHITECTURE_M68K
203 # define LIB_ARCH_TUPLE "m68k-linux-gnu"
204 #elif defined(__tilegx__)
205 # define native_architecture() ARCHITECTURE_TILEGX
206 # define LIB_ARCH_TUPLE "tilegx-linux-gnu"
207 #elif defined(__cris__)
208 # define native_architecture() ARCHITECTURE_CRIS
209 # error "Missing LIB_ARCH_TUPLE for CRIS"
210 #elif defined(__nios2__)
211 # define native_architecture() ARCHITECTURE_NIOS2
212 # define LIB_ARCH_TUPLE "nios2-linux-gnu"
213 #elif defined(__riscv__) || defined(__riscv)
214 /* __riscv__ is obsolete, remove in 2018 */
215 # if __SIZEOF_POINTER__ == 4
216 # define native_architecture() ARCHITECTURE_RISCV32
217 # define LIB_ARCH_TUPLE "riscv32-linux-gnu"
218 # elif __SIZEOF_POINTER__ == 8
219 # define native_architecture() ARCHITECTURE_RISCV64
220 # define LIB_ARCH_TUPLE "riscv64-linux-gnu"
222 # error "Unrecognized riscv architecture variant"
225 # error "Please register your architecture here!"
228 const char *architecture_to_string(int a
) _const_
;
229 int architecture_from_string(const char *s
) _pure_
;