1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2014 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 /* A cleaned up architecture definition. We don't want to get lost in
29 * processor features, models, generations or even ABIs. Hence we
30 * focus on general family, and distuignish word width and
39 ARCHITECTURE_PPC64_LE,
42 ARCHITECTURE_PARISC64,
50 ARCHITECTURE_MIPS64_LE,
55 ARCHITECTURE_ARM64_BE,
62 _ARCHITECTURE_INVALID = -1
65 int uname_architecture(void);
68 * LIB_ARCH_TUPLE should resolve to the local library path
69 * architecture tuple systemd is built for, according to the Debian
72 * https://wiki.debian.org/Multiarch/Tuples
74 * This is used in library search paths that should understand
75 * Debian's paths on all distributions.
78 #if defined(__x86_64__)
79 # define native_architecture() ARCHITECTURE_X86_64
80 # define LIB_ARCH_TUPLE "x86_64-linux-gnu"
81 #elif defined(__i386__)
82 # define native_architecture() ARCHITECTURE_X86
83 # define LIB_ARCH_TUPLE "i386-linux-gnu"
84 #elif defined(__powerpc64__)
85 # if __BYTE_ORDER == __BIG_ENDIAN
86 # define native_architecture() ARCHITECTURE_PPC64
87 # define LIB_ARCH_TUPLE "ppc64-linux-gnu"
89 # define native_architecture() ARCHITECTURE_PPC64_LE
90 # define LIB_ARCH_TUPLE "powerpc64le-linux-gnu"
92 #elif defined(__powerpc__)
93 # if __BYTE_ORDER == __BIG_ENDIAN
94 # define native_architecture() ARCHITECTURE_PPC
95 # define LIB_ARCH_TUPLE "powerpc-linux-gnu"
97 # define native_architecture() ARCHITECTURE_PPC_LE
98 # error "Missing LIB_ARCH_TUPLE for PPCLE"
100 #elif defined(__ia64__)
101 # define native_architecture() ARCHITECTURE_IA64
102 # define LIB_ARCH_TUPLE "ia64-linux-gnu"
103 #elif defined(__hppa64__)
104 # define native_architecture() ARCHITECTURE_PARISC64
105 # error "Missing LIB_ARCH_TUPLE for HPPA64"
106 #elif defined(__hppa__)
107 # define native_architecture() ARCHITECTURE_PARISC
108 # define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
109 #elif defined(__s390x__)
110 # define native_architecture() ARCHITECTURE_S390X
111 # define LIB_ARCH_TUPLE "s390x-linux-gnu"
112 #elif defined(__s390__)
113 # define native_architecture() ARCHITECTURE_S390
114 # define LIB_ARCH_TUPLE "s390-linux-gnu"
115 #elif defined(__sparc64__)
116 # define native_architecture() ARCHITECTURE_SPARC64
117 # define LIB_ARCH_TUPLE "sparc64-linux-gnu"
118 #elif defined(__sparc__)
119 # define native_architecture() ARCHITECTURE_SPARC
120 # define LIB_ARCH_TUPLE "sparc-linux-gnu"
121 #elif defined(__mips64__)
122 # if __BYTE_ORDER == __BIG_ENDIAN
123 # define native_architecture() ARCHITECTURE_MIPS64
124 # error "Missing LIB_ARCH_TUPLE for MIPS64"
126 # define native_architecture() ARCHITECTURE_MIPS64_LE
127 # error "Missing LIB_ARCH_TUPLE for MIPS64_LE"
129 #elif defined(__mips__)
130 # if __BYTE_ORDER == __BIG_ENDIAN
131 # define native_architecture() ARCHITECTURE_MIPS
132 # define LIB_ARCH_TUPLE "mips-linux-gnu"
134 # define native_architecture() ARCHITECTURE_MIPS_LE
135 # define LIB_ARCH_TUPLE "mipsel-linux-gnu"
137 #elif defined(__alpha__)
138 # define native_architecture() ARCHITECTURE_ALPHA
139 # define LIB_ARCH_TUPLE "alpha-linux-gnu"
140 #elif defined(__aarch64__)
141 # if __BYTE_ORDER == __BIG_ENDIAN
142 # define native_architecture() ARCHITECTURE_ARM64_BE
143 # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
145 # define native_architecture() ARCHITECTURE_ARM64
146 # define LIB_ARCH_TUPLE "aarch64-linux-gnu"
148 #elif defined(__arm__)
149 # if __BYTE_ORDER == __BIG_ENDIAN
150 # define native_architecture() ARCHITECTURE_ARM_BE
151 # if defined(__ARM_EABI__)
152 # if defined(__ARM_PCS_VFP)
153 # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
155 # define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
158 # define LIB_ARCH_TUPLE "armeb-linux-gnu"
161 # define native_architecture() ARCHITECTURE_ARM
162 # if defined(__ARM_EABI__)
163 # if defined(__ARM_PCS_VFP)
164 # define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
166 # define LIB_ARCH_TUPLE "arm-linux-gnueabi"
169 # define LIB_ARCH_TUPLE "arm-linux-gnu"
172 #elif defined(__sh64__)
173 # define native_architecture() ARCHITECTURE_SH64
174 # error "Missing LIB_ARCH_TUPLE for SH64"
175 #elif defined(__sh__)
176 # define native_architecture() ARCHITECTURE_SH
177 # define LIB_ARCH_TUPLE "sh4-linux-gnu"
178 #elif defined(__m68k__)
179 # define native_architecture() ARCHITECTURE_M68K
180 # define LIB_ARCH_TUPLE "m68k-linux-gnu"
181 #elif defined(__tilegx__)
182 # define native_architecture() ARCHITECTURE_TILEGX
183 # error "Missing LIB_ARCH_TUPLE for TILEGX"
184 #elif defined(__cris__)
185 # define native_architecture() ARCHITECTURE_CRIS
186 # error "Missing LIB_ARCH_TUPLE for CRIS"
188 # error "Please register your architecture here!"
191 const char *architecture_to_string(int a) _const_;
192 int architecture_from_string(const char *s) _pure_;