]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/architecture.h
Merge pull request #3151 from keszybz/pr3149-2
[thirdparty/systemd.git] / src / basic / architecture.h
CommitLineData
099524d7
LP
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2014 Lennart Poettering
7
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.
12
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.
17
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/>.
20***/
21
6017365a
LP
22#include <endian.h>
23
a8fbdf54 24#include "macro.h"
099524d7
LP
25#include "util.h"
26
579af519
LP
27/* A cleaned up architecture definition. We don't want to get lost in
28 * processor features, models, generations or even ABIs. Hence we
45afd519 29 * focus on general family, and distinguish word width and
06b643e7 30 * endianness. */
9a00f57a 31
592fd144 32enum {
099524d7
LP
33 ARCHITECTURE_X86 = 0,
34 ARCHITECTURE_X86_64,
35 ARCHITECTURE_PPC,
ae0e60fb 36 ARCHITECTURE_PPC_LE,
099524d7 37 ARCHITECTURE_PPC64,
ae0e60fb 38 ARCHITECTURE_PPC64_LE,
099524d7
LP
39 ARCHITECTURE_IA64,
40 ARCHITECTURE_PARISC,
41 ARCHITECTURE_PARISC64,
42 ARCHITECTURE_S390,
43 ARCHITECTURE_S390X,
44 ARCHITECTURE_SPARC,
45 ARCHITECTURE_SPARC64,
46 ARCHITECTURE_MIPS,
9a00f57a 47 ARCHITECTURE_MIPS_LE,
099524d7 48 ARCHITECTURE_MIPS64,
9a00f57a 49 ARCHITECTURE_MIPS64_LE,
099524d7
LP
50 ARCHITECTURE_ALPHA,
51 ARCHITECTURE_ARM,
52 ARCHITECTURE_ARM_BE,
53 ARCHITECTURE_ARM64,
54 ARCHITECTURE_ARM64_BE,
55 ARCHITECTURE_SH,
56 ARCHITECTURE_SH64,
57 ARCHITECTURE_M68K,
46eea341 58 ARCHITECTURE_TILEGX,
86bafac9 59 ARCHITECTURE_CRIS,
099524d7
LP
60 _ARCHITECTURE_MAX,
61 _ARCHITECTURE_INVALID = -1
592fd144 62};
099524d7 63
592fd144 64int uname_architecture(void);
099524d7 65
9a00f57a 66/*
613e3a26
LP
67 * LIB_ARCH_TUPLE should resolve to the local library path
68 * architecture tuple systemd is built for, according to the Debian
69 * tuple list:
9a00f57a
LP
70 *
71 * https://wiki.debian.org/Multiarch/Tuples
72 *
613e3a26
LP
73 * This is used in library search paths that should understand
74 * Debian's paths on all distributions.
9a00f57a
LP
75 */
76
099524d7
LP
77#if defined(__x86_64__)
78# define native_architecture() ARCHITECTURE_X86_64
613e3a26 79# define LIB_ARCH_TUPLE "x86_64-linux-gnu"
0c0fea07 80# define SECONDARY_ARCHITECTURE ARCHITECTURE_X86
099524d7
LP
81#elif defined(__i386__)
82# define native_architecture() ARCHITECTURE_X86
613e3a26 83# define LIB_ARCH_TUPLE "i386-linux-gnu"
099524d7 84#elif defined(__powerpc64__)
4f4b92ba 85# if __BYTE_ORDER == __BIG_ENDIAN
ae0e60fb 86# define native_architecture() ARCHITECTURE_PPC64
613e3a26 87# define LIB_ARCH_TUPLE "ppc64-linux-gnu"
0c0fea07 88# define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC
ae0e60fb
LP
89# else
90# define native_architecture() ARCHITECTURE_PPC64_LE
37d6781b 91# define LIB_ARCH_TUPLE "powerpc64le-linux-gnu"
0c0fea07 92# define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC_LE
ae0e60fb 93# endif
099524d7 94#elif defined(__powerpc__)
4f4b92ba 95# if __BYTE_ORDER == __BIG_ENDIAN
ae0e60fb 96# define native_architecture() ARCHITECTURE_PPC
613e3a26 97# define LIB_ARCH_TUPLE "powerpc-linux-gnu"
ae0e60fb
LP
98# else
99# define native_architecture() ARCHITECTURE_PPC_LE
613e3a26 100# error "Missing LIB_ARCH_TUPLE for PPCLE"
ae0e60fb 101# endif
099524d7
LP
102#elif defined(__ia64__)
103# define native_architecture() ARCHITECTURE_IA64
613e3a26 104# define LIB_ARCH_TUPLE "ia64-linux-gnu"
099524d7
LP
105#elif defined(__hppa64__)
106# define native_architecture() ARCHITECTURE_PARISC64
613e3a26 107# error "Missing LIB_ARCH_TUPLE for HPPA64"
099524d7
LP
108#elif defined(__hppa__)
109# define native_architecture() ARCHITECTURE_PARISC
613e3a26 110# define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
099524d7
LP
111#elif defined(__s390x__)
112# define native_architecture() ARCHITECTURE_S390X
613e3a26 113# define LIB_ARCH_TUPLE "s390x-linux-gnu"
0c0fea07 114# define SECONDARY_ARCHITECTURE ARCHITECTURE_S390
099524d7
LP
115#elif defined(__s390__)
116# define native_architecture() ARCHITECTURE_S390
613e3a26 117# define LIB_ARCH_TUPLE "s390-linux-gnu"
099524d7
LP
118#elif defined(__sparc64__)
119# define native_architecture() ARCHITECTURE_SPARC64
613e3a26 120# define LIB_ARCH_TUPLE "sparc64-linux-gnu"
099524d7
LP
121#elif defined(__sparc__)
122# define native_architecture() ARCHITECTURE_SPARC
613e3a26 123# define LIB_ARCH_TUPLE "sparc-linux-gnu"
099524d7 124#elif defined(__mips64__)
4f4b92ba 125# if __BYTE_ORDER == __BIG_ENDIAN
9a00f57a 126# define native_architecture() ARCHITECTURE_MIPS64
613e3a26 127# error "Missing LIB_ARCH_TUPLE for MIPS64"
9a00f57a
LP
128# else
129# define native_architecture() ARCHITECTURE_MIPS64_LE
613e3a26 130# error "Missing LIB_ARCH_TUPLE for MIPS64_LE"
9a00f57a 131# endif
099524d7 132#elif defined(__mips__)
4f4b92ba 133# if __BYTE_ORDER == __BIG_ENDIAN
9a00f57a 134# define native_architecture() ARCHITECTURE_MIPS
613e3a26 135# define LIB_ARCH_TUPLE "mips-linux-gnu"
9a00f57a
LP
136# else
137# define native_architecture() ARCHITECTURE_MIPS_LE
613e3a26 138# define LIB_ARCH_TUPLE "mipsel-linux-gnu"
568981d2 139# endif
099524d7
LP
140#elif defined(__alpha__)
141# define native_architecture() ARCHITECTURE_ALPHA
613e3a26 142# define LIB_ARCH_TUPLE "alpha-linux-gnu"
099524d7 143#elif defined(__aarch64__)
4f4b92ba 144# if __BYTE_ORDER == __BIG_ENDIAN
099524d7 145# define native_architecture() ARCHITECTURE_ARM64_BE
613e3a26 146# define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
099524d7
LP
147# else
148# define native_architecture() ARCHITECTURE_ARM64
613e3a26 149# define LIB_ARCH_TUPLE "aarch64-linux-gnu"
099524d7
LP
150# endif
151#elif defined(__arm__)
4f4b92ba 152# if __BYTE_ORDER == __BIG_ENDIAN
099524d7 153# define native_architecture() ARCHITECTURE_ARM_BE
579af519
LP
154# if defined(__ARM_EABI__)
155# if defined(__ARM_PCS_VFP)
156# define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
157# else
158# define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
159# endif
0881d7af 160# else
579af519 161# define LIB_ARCH_TUPLE "armeb-linux-gnu"
0881d7af 162# endif
099524d7 163# else
0881d7af 164# define native_architecture() ARCHITECTURE_ARM
2a9899d8
ZJS
165# if defined(__ARM_EABI__)
166# if defined(__ARM_PCS_VFP)
167# define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
168# else
169# define LIB_ARCH_TUPLE "arm-linux-gnueabi"
170# endif
fd3b401e 171# else
2a9899d8 172# define LIB_ARCH_TUPLE "arm-linux-gnu"
fd3b401e 173# endif
099524d7
LP
174# endif
175#elif defined(__sh64__)
176# define native_architecture() ARCHITECTURE_SH64
613e3a26 177# error "Missing LIB_ARCH_TUPLE for SH64"
099524d7
LP
178#elif defined(__sh__)
179# define native_architecture() ARCHITECTURE_SH
613e3a26 180# define LIB_ARCH_TUPLE "sh4-linux-gnu"
099524d7
LP
181#elif defined(__m68k__)
182# define native_architecture() ARCHITECTURE_M68K
613e3a26 183# define LIB_ARCH_TUPLE "m68k-linux-gnu"
46eea341
HGB
184#elif defined(__tilegx__)
185# define native_architecture() ARCHITECTURE_TILEGX
613e3a26 186# error "Missing LIB_ARCH_TUPLE for TILEGX"
86bafac9
UTL
187#elif defined(__cris__)
188# define native_architecture() ARCHITECTURE_CRIS
613e3a26 189# error "Missing LIB_ARCH_TUPLE for CRIS"
099524d7 190#else
568981d2 191# error "Please register your architecture here!"
099524d7
LP
192#endif
193
592fd144
LP
194const char *architecture_to_string(int a) _const_;
195int architecture_from_string(const char *s) _pure_;