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/>.
26 /* A cleaned up architecture definition. We don't want to get lost in
27 * processor features, models, generations or even ABIs. Hence we
28 * focus on general family, and distuignish word width and
31 typedef enum Architecture {
37 ARCHITECTURE_PPC64_LE,
40 ARCHITECTURE_PARISC64,
48 ARCHITECTURE_MIPS64_LE,
53 ARCHITECTURE_ARM64_BE,
60 _ARCHITECTURE_INVALID = -1
63 Architecture uname_architecture(void);
66 * LIB_ARCH_TUPLE should resolve to the local library path
67 * architecture tuple systemd is built for, according to the Debian
70 * https://wiki.debian.org/Multiarch/Tuples
72 * This is used in library search paths that should understand
73 * Debian's paths on all distributions.
76 #if defined(__x86_64__)
77 # define native_architecture() ARCHITECTURE_X86_64
78 # define LIB_ARCH_TUPLE "x86_64-linux-gnu"
79 #elif defined(__i386__)
80 # define native_architecture() ARCHITECTURE_X86
81 # define LIB_ARCH_TUPLE "i386-linux-gnu"
82 #elif defined(__powerpc64__)
83 # if defined(WORDS_BIGENDIAN)
84 # define native_architecture() ARCHITECTURE_PPC64
85 # define LIB_ARCH_TUPLE "ppc64-linux-gnu"
87 # define native_architecture() ARCHITECTURE_PPC64_LE
88 # error "Missing LIB_ARCH_TUPLE for PPC64LE"
90 #elif defined(__powerpc__)
91 # if defined(WORDS_BIGENDIAN)
92 # define native_architecture() ARCHITECTURE_PPC
93 # define LIB_ARCH_TUPLE "powerpc-linux-gnu"
95 # define native_architecture() ARCHITECTURE_PPC_LE
96 # error "Missing LIB_ARCH_TUPLE for PPCLE"
98 #elif defined(__ia64__)
99 # define native_architecture() ARCHITECTURE_IA64
100 # define LIB_ARCH_TUPLE "ia64-linux-gnu"
101 #elif defined(__hppa64__)
102 # define native_architecture() ARCHITECTURE_PARISC64
103 # error "Missing LIB_ARCH_TUPLE for HPPA64"
104 #elif defined(__hppa__)
105 # define native_architecture() ARCHITECTURE_PARISC
106 # define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
107 #elif defined(__s390x__)
108 # define native_architecture() ARCHITECTURE_S390X
109 # define LIB_ARCH_TUPLE "s390x-linux-gnu"
110 #elif defined(__s390__)
111 # define native_architecture() ARCHITECTURE_S390
112 # define LIB_ARCH_TUPLE "s390-linux-gnu"
113 #elif defined(__sparc64__)
114 # define native_architecture() ARCHITECTURE_SPARC64
115 # define LIB_ARCH_TUPLE "sparc64-linux-gnu"
116 #elif defined(__sparc__)
117 # define native_architecture() ARCHITECTURE_SPARC
118 # define LIB_ARCH_TUPLE "sparc-linux-gnu"
119 #elif defined(__mips64__)
120 # if defined(WORDS_BIGENDIAN)
121 # define native_architecture() ARCHITECTURE_MIPS64
122 # error "Missing LIB_ARCH_TUPLE for MIPS64"
124 # define native_architecture() ARCHITECTURE_MIPS64_LE
125 # error "Missing LIB_ARCH_TUPLE for MIPS64_LE"
127 #elif defined(__mips__)
128 # if defined(WORDS_BIGENDIAN)
129 # define native_architecture() ARCHITECTURE_MIPS
130 # define LIB_ARCH_TUPLE "mips-linux-gnu"
132 # define native_architecture() ARCHITECTURE_MIPS_LE
133 # define LIB_ARCH_TUPLE "mipsel-linux-gnu"
135 #elif defined(__alpha__)
136 # define native_architecture() ARCHITECTURE_ALPHA
137 # define LIB_ARCH_TUPLE "alpha-linux-gnu"
138 #elif defined(__aarch64__)
139 # if defined(WORDS_BIGENDIAN)
140 # define native_architecture() ARCHITECTURE_ARM64_BE
141 # define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
143 # define native_architecture() ARCHITECTURE_ARM64
144 # define LIB_ARCH_TUPLE "aarch64-linux-gnu"
146 #elif defined(__arm__)
147 # if defined(WORDS_BIGENDIAN)
148 # define native_architecture() ARCHITECTURE_ARM_BE
149 # if defined(__ARM_EABI__)
150 # if defined(__ARM_PCS_VFP)
151 # define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
153 # define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
156 # define LIB_ARCH_TUPLE "armeb-linux-gnu"
159 # define native_architecture() ARCHITECTURE_ARM
160 # if defined(__ARM_EABI__)
161 # if defined(__ARM_PCS_VFP)
162 # define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
164 # define LIB_ARCH_TUPLE "arm-linux-gnueabi"
167 # define LIB_ARCH_TUPLE "arm-linux-gnu"
170 #elif defined(__sh64__)
171 # define native_architecture() ARCHITECTURE_SH64
172 # error "Missing LIB_ARCH_TUPLE for SH64"
173 #elif defined(__sh__)
174 # define native_architecture() ARCHITECTURE_SH
175 # define LIB_ARCH_TUPLE "sh4-linux-gnu"
176 #elif defined(__m68k__)
177 # define native_architecture() ARCHITECTURE_M68K
178 # define LIB_ARCH_TUPLE "m68k-linux-gnu"
179 #elif defined(__tilegx__)
180 # define native_architecture() ARCHITECTURE_TILEGX
181 # error "Missing LIB_ARCH_TUPLE for TILEGX"
182 #elif defined(__cris__)
183 # define native_architecture() ARCHITECTURE_CRIS
184 # error "Missing LIB_ARCH_TUPLE for CRIS"
186 #error "Please register your architecture here!"
189 const char *architecture_to_string(Architecture a) _const_;
190 Architecture architecture_from_string(const char *s) _pure_;