chiark / gitweb /
shared: add LIB_ARCH tuples for BE ARM archs
[elogind.git] / src / shared / architecture.h
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
26 /* A cleaned up architecture definition */
27
28 typedef enum Architecture {
29         ARCHITECTURE_X86 = 0,
30         ARCHITECTURE_X86_64,
31         ARCHITECTURE_PPC,
32         ARCHITECTURE_PPC_LE,
33         ARCHITECTURE_PPC64,
34         ARCHITECTURE_PPC64_LE,
35         ARCHITECTURE_IA64,
36         ARCHITECTURE_PARISC,
37         ARCHITECTURE_PARISC64,
38         ARCHITECTURE_S390,
39         ARCHITECTURE_S390X,
40         ARCHITECTURE_SPARC,
41         ARCHITECTURE_SPARC64,
42         ARCHITECTURE_MIPS,
43         ARCHITECTURE_MIPS_LE,
44         ARCHITECTURE_MIPS64,
45         ARCHITECTURE_MIPS64_LE,
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,
54         ARCHITECTURE_TILEGX,
55         ARCHITECTURE_CRIS,
56         _ARCHITECTURE_MAX,
57         _ARCHITECTURE_INVALID = -1
58 } Architecture;
59
60 Architecture uname_architecture(void);
61
62 /*
63  * LIB_ARCH_TUPLE should resolve to the local library path
64  * architecture tuple systemd is built for, according to the Debian
65  * tuple list:
66  *
67  * https://wiki.debian.org/Multiarch/Tuples
68  *
69  * This is used in library search paths that should understand
70  * Debian's paths on all distributions.
71  */
72
73 #if defined(__x86_64__)
74 #  define native_architecture() ARCHITECTURE_X86_64
75 #  define LIB_ARCH_TUPLE "x86_64-linux-gnu"
76 #elif defined(__i386__)
77 #  define native_architecture() ARCHITECTURE_X86
78 #  define LIB_ARCH_TUPLE "i386-linux-gnu"
79 #elif defined(__powerpc64__)
80 #  if defined(WORDS_BIGENDIAN)
81 #    define native_architecture() ARCHITECTURE_PPC64
82 #    define LIB_ARCH_TUPLE "ppc64-linux-gnu"
83 #  else
84 #    define native_architecture() ARCHITECTURE_PPC64_LE
85 #    error "Missing LIB_ARCH_TUPLE for PPC64LE"
86 #  endif
87 #elif defined(__powerpc__)
88 #  if defined(WORDS_BIGENDIAN)
89 #    define native_architecture() ARCHITECTURE_PPC
90 #    define LIB_ARCH_TUPLE "powerpc-linux-gnu"
91 #  else
92 #    define native_architecture() ARCHITECTURE_PPC_LE
93 #    error "Missing LIB_ARCH_TUPLE for PPCLE"
94 #  endif
95 #elif defined(__ia64__)
96 #  define native_architecture() ARCHITECTURE_IA64
97 #  define LIB_ARCH_TUPLE "ia64-linux-gnu"
98 #elif defined(__hppa64__)
99 #  define native_architecture() ARCHITECTURE_PARISC64
100 #  error "Missing LIB_ARCH_TUPLE for HPPA64"
101 #elif defined(__hppa__)
102 #  define native_architecture() ARCHITECTURE_PARISC
103 #  define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
104 #elif defined(__s390x__)
105 #  define native_architecture() ARCHITECTURE_S390X
106 #  define LIB_ARCH_TUPLE "s390x-linux-gnu"
107 #elif defined(__s390__)
108 #  define native_architecture() ARCHITECTURE_S390
109 #  define LIB_ARCH_TUPLE "s390-linux-gnu"
110 #elif defined(__sparc64__)
111 #  define native_architecture() ARCHITECTURE_SPARC64
112 #  define LIB_ARCH_TUPLE "sparc64-linux-gnu"
113 #elif defined(__sparc__)
114 #  define native_architecture() ARCHITECTURE_SPARC
115 #  define LIB_ARCH_TUPLE "sparc-linux-gnu"
116 #elif defined(__mips64__)
117 #  if defined(WORDS_BIGENDIAN)
118 #    define native_architecture() ARCHITECTURE_MIPS64
119 #    error "Missing LIB_ARCH_TUPLE for MIPS64"
120 #  else
121 #    define native_architecture() ARCHITECTURE_MIPS64_LE
122 #    error "Missing LIB_ARCH_TUPLE for MIPS64_LE"
123 #  endif
124 #elif defined(__mips__)
125 #  if defined(WORDS_BIGENDIAN)
126 #    define native_architecture() ARCHITECTURE_MIPS
127 #    define LIB_ARCH_TUPLE "mips-linux-gnu"
128 #  else
129 #    define native_architecture() ARCHITECTURE_MIPS_LE
130 #    define LIB_ARCH_TUPLE "mipsel-linux-gnu"
131 #endif
132 #elif defined(__alpha__)
133 #  define native_architecture() ARCHITECTURE_ALPHA
134 #  define LIB_ARCH_TUPLE "alpha-linux-gnu"
135 #elif defined(__aarch64__)
136 #  if defined(WORDS_BIGENDIAN)
137 #    define native_architecture() ARCHITECTURE_ARM64_BE
138 #    define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
139 #  else
140 #    define native_architecture() ARCHITECTURE_ARM64
141 #    define LIB_ARCH_TUPLE "aarch64-linux-gnu"
142 #  endif
143 #elif defined(__arm__)
144 #  if defined(WORDS_BIGENDIAN)
145 #    define native_architecture() ARCHITECTURE_ARM_BE
146 #    if defined(__ARM_PCS_VFP)
147 #      define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
148 #    else
149 #      define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
150 #    endif
151 #  else
152 #    define native_architecture() ARCHITECTURE_ARM
153 #    if defined(__ARM_PCS_VFP)
154 #      define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
155 #    else
156 #      define LIB_ARCH_TUPLE "arm-linux-gnueabi"
157 #    endif
158 #  endif
159 #elif defined(__sh64__)
160 #  define native_architecture() ARCHITECTURE_SH64
161 #  error "Missing LIB_ARCH_TUPLE for SH64"
162 #elif defined(__sh__)
163 #  define native_architecture() ARCHITECTURE_SH
164 #  define LIB_ARCH_TUPLE "sh4-linux-gnu"
165 #elif defined(__m68k__)
166 #  define native_architecture() ARCHITECTURE_M68K
167 #  define LIB_ARCH_TUPLE "m68k-linux-gnu"
168 #elif defined(__tilegx__)
169 #  define native_architecture() ARCHITECTURE_TILEGX
170 #  error "Missing LIB_ARCH_TUPLE for TILEGX"
171 #elif defined(__cris__)
172 #  define native_architecture() ARCHITECTURE_CRIS
173 #  error "Missing LIB_ARCH_TUPLE for CRIS"
174 #else
175 #error "Please register your architecture here!"
176 #endif
177
178 const char *architecture_to_string(Architecture a) _const_;
179 Architecture architecture_from_string(const char *s) _pure_;