]>
Commit | Line | Data |
---|---|---|
099524d7 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2014 Lennart Poettering | |
9 | ||
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. | |
14 | ||
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. | |
19 | ||
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/>. | |
22 | ***/ | |
23 | ||
24 | #include "util.h" | |
25 | ||
9a00f57a LP |
26 | /* A cleaned up architecture definition */ |
27 | ||
099524d7 LP |
28 | typedef enum Architecture { |
29 | ARCHITECTURE_X86 = 0, | |
30 | ARCHITECTURE_X86_64, | |
31 | ARCHITECTURE_PPC, | |
ae0e60fb | 32 | ARCHITECTURE_PPC_LE, |
099524d7 | 33 | ARCHITECTURE_PPC64, |
ae0e60fb | 34 | ARCHITECTURE_PPC64_LE, |
099524d7 LP |
35 | ARCHITECTURE_IA64, |
36 | ARCHITECTURE_PARISC, | |
37 | ARCHITECTURE_PARISC64, | |
38 | ARCHITECTURE_S390, | |
39 | ARCHITECTURE_S390X, | |
40 | ARCHITECTURE_SPARC, | |
41 | ARCHITECTURE_SPARC64, | |
42 | ARCHITECTURE_MIPS, | |
9a00f57a | 43 | ARCHITECTURE_MIPS_LE, |
099524d7 | 44 | ARCHITECTURE_MIPS64, |
9a00f57a | 45 | ARCHITECTURE_MIPS64_LE, |
099524d7 LP |
46 | ARCHITECTURE_ALPHA, |
47 | ARCHITECTURE_ARM, | |
48 | ARCHITECTURE_ARM_BE, | |
49 | ARCHITECTURE_ARM64, | |
50 | ARCHITECTURE_ARM64_BE, | |
51 | ARCHITECTURE_SH, | |
52 | ARCHITECTURE_SH64, | |
53 | ARCHITECTURE_M68K, | |
46eea341 | 54 | ARCHITECTURE_TILEGX, |
86bafac9 | 55 | ARCHITECTURE_CRIS, |
099524d7 LP |
56 | _ARCHITECTURE_MAX, |
57 | _ARCHITECTURE_INVALID = -1 | |
58 | } Architecture; | |
59 | ||
60 | Architecture uname_architecture(void); | |
61 | ||
9a00f57a LP |
62 | /* |
63 | * ARCH_TUPLE should resolve to the local architecture systemd is | |
64 | * built for, according to the Debian tuple list: | |
65 | * | |
66 | * https://wiki.debian.org/Multiarch/Tuples | |
67 | * | |
68 | */ | |
69 | ||
099524d7 LP |
70 | #if defined(__x86_64__) |
71 | # define native_architecture() ARCHITECTURE_X86_64 | |
9a00f57a | 72 | # define ARCH_TUPLE "x86_64-linux-gnu" |
099524d7 LP |
73 | #elif defined(__i386__) |
74 | # define native_architecture() ARCHITECTURE_X86 | |
9a00f57a | 75 | # define ARCH_TUPLE "i386-linux-gnu" |
099524d7 | 76 | #elif defined(__powerpc64__) |
ae0e60fb LP |
77 | # if defined(WORDS_BIGENDIAN) |
78 | # define native_architecture() ARCHITECTURE_PPC64 | |
9a00f57a | 79 | # define ARCH_TUPLE "ppc64-linux-gnu" |
ae0e60fb LP |
80 | # else |
81 | # define native_architecture() ARCHITECTURE_PPC64_LE | |
9a00f57a | 82 | # error "Missing ARCH_TUPLE for PPC64LE" |
ae0e60fb | 83 | # endif |
099524d7 | 84 | #elif defined(__powerpc__) |
ae0e60fb LP |
85 | # if defined(WORDS_BIGENDIAN) |
86 | # define native_architecture() ARCHITECTURE_PPC | |
9a00f57a | 87 | # define ARCH_TUPLE "powerpc-linux-gnu" |
ae0e60fb LP |
88 | # else |
89 | # define native_architecture() ARCHITECTURE_PPC_LE | |
9a00f57a | 90 | # error "Missing ARCH_TUPLE for PPCLE" |
ae0e60fb | 91 | # endif |
099524d7 LP |
92 | #elif defined(__ia64__) |
93 | # define native_architecture() ARCHITECTURE_IA64 | |
9a00f57a | 94 | # define ARCH_TUPLE "ia64-linux-gnu" |
099524d7 LP |
95 | #elif defined(__hppa64__) |
96 | # define native_architecture() ARCHITECTURE_PARISC64 | |
9a00f57a | 97 | # error "Missing ARCH_TUPLE for HPPA64" |
099524d7 LP |
98 | #elif defined(__hppa__) |
99 | # define native_architecture() ARCHITECTURE_PARISC | |
9a00f57a | 100 | # define ARCH_TUPLE "hppa‑linux‑gnu" |
099524d7 LP |
101 | #elif defined(__s390x__) |
102 | # define native_architecture() ARCHITECTURE_S390X | |
9a00f57a | 103 | # define ARCH_TUPLE "s390x-linux-gnu" |
099524d7 LP |
104 | #elif defined(__s390__) |
105 | # define native_architecture() ARCHITECTURE_S390 | |
9a00f57a | 106 | # define ARCH_TUPLE "s390-linux-gnu" |
099524d7 LP |
107 | #elif defined(__sparc64__) |
108 | # define native_architecture() ARCHITECTURE_SPARC64 | |
9a00f57a | 109 | # define ARCH_TUPLE "sparc64-linux-gnu" |
099524d7 LP |
110 | #elif defined(__sparc__) |
111 | # define native_architecture() ARCHITECTURE_SPARC | |
9a00f57a | 112 | # define ARCH_TUPLE "sparc-linux-gnu" |
099524d7 | 113 | #elif defined(__mips64__) |
9a00f57a LP |
114 | # if defined(WORDS_BIGENDIAN) |
115 | # define native_architecture() ARCHITECTURE_MIPS64 | |
116 | # error "Missing ARCH_TUPLE for MIPS64" | |
117 | # else | |
118 | # define native_architecture() ARCHITECTURE_MIPS64_LE | |
119 | # error "Missing ARCH_TUPLE for MIPS64_LE" | |
120 | # endif | |
099524d7 | 121 | #elif defined(__mips__) |
9a00f57a LP |
122 | # if defined(WORDS_BIGENDIAN) |
123 | # define native_architecture() ARCHITECTURE_MIPS | |
124 | # define ARCH_TUPLE "mips-linux-gnu" | |
125 | # else | |
126 | # define native_architecture() ARCHITECTURE_MIPS_LE | |
127 | # define ARCH_TUPLE "mipsel-linux-gnu" | |
128 | #endif | |
099524d7 LP |
129 | #elif defined(__alpha__) |
130 | # define native_architecture() ARCHITECTURE_ALPHA | |
9a00f57a | 131 | # define ARCH_TUPLE "alpha-linux-gnu" |
099524d7 | 132 | #elif defined(__aarch64__) |
9bd9f43f | 133 | # if defined(WORDS_BIGENDIAN) |
099524d7 | 134 | # define native_architecture() ARCHITECTURE_ARM64_BE |
9a00f57a | 135 | # define ARCH_TUPLE "aarch64_be-linux-gnu" |
099524d7 LP |
136 | # else |
137 | # define native_architecture() ARCHITECTURE_ARM64 | |
9a00f57a | 138 | # define ARCH_TUPLE "aarch64-linux-gnu" |
099524d7 LP |
139 | # endif |
140 | #elif defined(__arm__) | |
9bd9f43f | 141 | # if defined(WORDS_BIGENDIAN) |
099524d7 | 142 | # define native_architecture() ARCHITECTURE_ARM_BE |
9a00f57a | 143 | # error "Missing ARCH_TUPLE for ARM_BE" |
099524d7 LP |
144 | # else |
145 | # define native_architecture() ARCHITECTURE_ARM | |
9a00f57a | 146 | # error "Missing ARCH_TUPLE for ARM" |
099524d7 LP |
147 | # endif |
148 | #elif defined(__sh64__) | |
149 | # define native_architecture() ARCHITECTURE_SH64 | |
9a00f57a | 150 | # error "Missing ARCH_TUPLE for SH64" |
099524d7 LP |
151 | #elif defined(__sh__) |
152 | # define native_architecture() ARCHITECTURE_SH | |
9a00f57a | 153 | # define ARCH_TUPLE "sh4-linux-gnu" |
099524d7 LP |
154 | #elif defined(__m68k__) |
155 | # define native_architecture() ARCHITECTURE_M68K | |
9a00f57a | 156 | # define ARCH_TUPLE "m68k-linux-gnu" |
46eea341 HGB |
157 | #elif defined(__tilegx__) |
158 | # define native_architecture() ARCHITECTURE_TILEGX | |
9a00f57a | 159 | # error "Missing ARCH_TUPLE for TILEGX" |
86bafac9 UTL |
160 | #elif defined(__cris__) |
161 | # define native_architecture() ARCHITECTURE_CRIS | |
9a00f57a | 162 | # error "Missing ARCH_TUPLE for CRIS" |
099524d7 LP |
163 | #else |
164 | #error "Please register your architecture here!" | |
165 | #endif | |
166 | ||
167 | const char *architecture_to_string(Architecture a) _const_; | |
168 | Architecture architecture_from_string(const char *s) _pure_; |