X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Farchitecture.h;h=cb82418a5e4b62162aa28b9511133f1987a29c58;hp=08079244dc15c7acb86f1c915c7a66351f008fd9;hb=b6b1849830f5e4a6065c3b0c993668e500c954d3;hpb=9a00f57a5ba7ed431e6bac8d8b36518708503b4e diff --git a/src/shared/architecture.h b/src/shared/architecture.h index 08079244d..cb82418a5 100644 --- a/src/shared/architecture.h +++ b/src/shared/architecture.h @@ -21,11 +21,16 @@ along with systemd; If not, see . ***/ +#include + #include "util.h" -/* A cleaned up architecture definition */ +/* A cleaned up architecture definition. We don't want to get lost in + * processor features, models, generations or even ABIs. Hence we + * focus on general family, and distuignish word width and + * endianness. */ -typedef enum Architecture { +enum { ARCHITECTURE_X86 = 0, ARCHITECTURE_X86_64, ARCHITECTURE_PPC, @@ -55,114 +60,133 @@ typedef enum Architecture { ARCHITECTURE_CRIS, _ARCHITECTURE_MAX, _ARCHITECTURE_INVALID = -1 -} Architecture; +}; -Architecture uname_architecture(void); +int uname_architecture(void); /* - * ARCH_TUPLE should resolve to the local architecture systemd is - * built for, according to the Debian tuple list: + * LIB_ARCH_TUPLE should resolve to the local library path + * architecture tuple systemd is built for, according to the Debian + * tuple list: * * https://wiki.debian.org/Multiarch/Tuples * + * This is used in library search paths that should understand + * Debian's paths on all distributions. */ #if defined(__x86_64__) # define native_architecture() ARCHITECTURE_X86_64 -# define ARCH_TUPLE "x86_64-linux-gnu" +# define LIB_ARCH_TUPLE "x86_64-linux-gnu" #elif defined(__i386__) # define native_architecture() ARCHITECTURE_X86 -# define ARCH_TUPLE "i386-linux-gnu" +# define LIB_ARCH_TUPLE "i386-linux-gnu" #elif defined(__powerpc64__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_PPC64 -# define ARCH_TUPLE "ppc64-linux-gnu" +# define LIB_ARCH_TUPLE "ppc64-linux-gnu" # else # define native_architecture() ARCHITECTURE_PPC64_LE -# error "Missing ARCH_TUPLE for PPC64LE" +# define LIB_ARCH_TUPLE "powerpc64le-linux-gnu" # endif #elif defined(__powerpc__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_PPC -# define ARCH_TUPLE "powerpc-linux-gnu" +# define LIB_ARCH_TUPLE "powerpc-linux-gnu" # else # define native_architecture() ARCHITECTURE_PPC_LE -# error "Missing ARCH_TUPLE for PPCLE" +# error "Missing LIB_ARCH_TUPLE for PPCLE" # endif #elif defined(__ia64__) # define native_architecture() ARCHITECTURE_IA64 -# define ARCH_TUPLE "ia64-linux-gnu" +# define LIB_ARCH_TUPLE "ia64-linux-gnu" #elif defined(__hppa64__) # define native_architecture() ARCHITECTURE_PARISC64 -# error "Missing ARCH_TUPLE for HPPA64" +# error "Missing LIB_ARCH_TUPLE for HPPA64" #elif defined(__hppa__) # define native_architecture() ARCHITECTURE_PARISC -# define ARCH_TUPLE "hppa‑linux‑gnu" +# define LIB_ARCH_TUPLE "hppa‑linux‑gnu" #elif defined(__s390x__) # define native_architecture() ARCHITECTURE_S390X -# define ARCH_TUPLE "s390x-linux-gnu" +# define LIB_ARCH_TUPLE "s390x-linux-gnu" #elif defined(__s390__) # define native_architecture() ARCHITECTURE_S390 -# define ARCH_TUPLE "s390-linux-gnu" +# define LIB_ARCH_TUPLE "s390-linux-gnu" #elif defined(__sparc64__) # define native_architecture() ARCHITECTURE_SPARC64 -# define ARCH_TUPLE "sparc64-linux-gnu" +# define LIB_ARCH_TUPLE "sparc64-linux-gnu" #elif defined(__sparc__) # define native_architecture() ARCHITECTURE_SPARC -# define ARCH_TUPLE "sparc-linux-gnu" +# define LIB_ARCH_TUPLE "sparc-linux-gnu" #elif defined(__mips64__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_MIPS64 -# error "Missing ARCH_TUPLE for MIPS64" +# error "Missing LIB_ARCH_TUPLE for MIPS64" # else # define native_architecture() ARCHITECTURE_MIPS64_LE -# error "Missing ARCH_TUPLE for MIPS64_LE" +# error "Missing LIB_ARCH_TUPLE for MIPS64_LE" # endif #elif defined(__mips__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_MIPS -# define ARCH_TUPLE "mips-linux-gnu" +# define LIB_ARCH_TUPLE "mips-linux-gnu" # else # define native_architecture() ARCHITECTURE_MIPS_LE -# define ARCH_TUPLE "mipsel-linux-gnu" -#endif +# define LIB_ARCH_TUPLE "mipsel-linux-gnu" +# endif #elif defined(__alpha__) # define native_architecture() ARCHITECTURE_ALPHA -# define ARCH_TUPLE "alpha-linux-gnu" +# define LIB_ARCH_TUPLE "alpha-linux-gnu" #elif defined(__aarch64__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_ARM64_BE -# define ARCH_TUPLE "aarch64_be-linux-gnu" +# define LIB_ARCH_TUPLE "aarch64_be-linux-gnu" # else # define native_architecture() ARCHITECTURE_ARM64 -# define ARCH_TUPLE "aarch64-linux-gnu" +# define LIB_ARCH_TUPLE "aarch64-linux-gnu" # endif #elif defined(__arm__) -# if defined(WORDS_BIGENDIAN) +# if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_ARM_BE -# error "Missing ARCH_TUPLE for ARM_BE" +# if defined(__ARM_EABI__) +# if defined(__ARM_PCS_VFP) +# define LIB_ARCH_TUPLE "armeb-linux-gnueabihf" +# else +# define LIB_ARCH_TUPLE "armeb-linux-gnueabi" +# endif +# else +# define LIB_ARCH_TUPLE "armeb-linux-gnu" +# endif # else # define native_architecture() ARCHITECTURE_ARM -# error "Missing ARCH_TUPLE for ARM" +# if defined(__ARM_EABI__) +# if defined(__ARM_PCS_VFP) +# define LIB_ARCH_TUPLE "arm-linux-gnueabihf" +# else +# define LIB_ARCH_TUPLE "arm-linux-gnueabi" +# endif +# else +# define LIB_ARCH_TUPLE "arm-linux-gnu" +# endif # endif #elif defined(__sh64__) # define native_architecture() ARCHITECTURE_SH64 -# error "Missing ARCH_TUPLE for SH64" +# error "Missing LIB_ARCH_TUPLE for SH64" #elif defined(__sh__) # define native_architecture() ARCHITECTURE_SH -# define ARCH_TUPLE "sh4-linux-gnu" +# define LIB_ARCH_TUPLE "sh4-linux-gnu" #elif defined(__m68k__) # define native_architecture() ARCHITECTURE_M68K -# define ARCH_TUPLE "m68k-linux-gnu" +# define LIB_ARCH_TUPLE "m68k-linux-gnu" #elif defined(__tilegx__) # define native_architecture() ARCHITECTURE_TILEGX -# error "Missing ARCH_TUPLE for TILEGX" +# error "Missing LIB_ARCH_TUPLE for TILEGX" #elif defined(__cris__) # define native_architecture() ARCHITECTURE_CRIS -# error "Missing ARCH_TUPLE for CRIS" +# error "Missing LIB_ARCH_TUPLE for CRIS" #else -#error "Please register your architecture here!" +# error "Please register your architecture here!" #endif -const char *architecture_to_string(Architecture a) _const_; -Architecture architecture_from_string(const char *s) _pure_; +const char *architecture_to_string(int a) _const_; +int architecture_from_string(const char *s) _pure_;