architecture.h revision 2a9899d862ec00ad2287e3bc97194054a8c9c479
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#pragma once
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/***
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen This file is part of systemd.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Copyright 2014 Lennart Poettering
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen systemd is free software; you can redistribute it and/or modify it
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen under the terms of the GNU Lesser General Public License as published by
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen the Free Software Foundation; either version 2.1 of the License, or
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen (at your option) any later version.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen systemd is distributed in the hope that it will be useful, but
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen WITHOUT ANY WARRANTY; without even the implied warranty of
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen Lesser General Public License for more details.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen You should have received a copy of the GNU Lesser General Public License
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen***/
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#include "util.h"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/* A cleaned up architecture definition */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersentypedef enum Architecture {
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_X86 = 0,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_X86_64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PPC,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PPC_LE,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PPC64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PPC64_LE,
c62c294fd521e5b65bb52f831773916bbc4cd90aThomas Hindoe Paaboel Andersen ARCHITECTURE_IA64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PARISC,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_PARISC64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_S390,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_S390X,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_SPARC,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_SPARC64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_MIPS,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_MIPS_LE,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_MIPS64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_MIPS64_LE,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_ALPHA,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_ARM,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_ARM_BE,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_ARM64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_ARM64_BE,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_SH,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_SH64,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_M68K,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_TILEGX,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen ARCHITECTURE_CRIS,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen _ARCHITECTURE_MAX,
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen _ARCHITECTURE_INVALID = -1
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen} Architecture;
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel AndersenArchitecture uname_architecture(void);
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen/*
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * LIB_ARCH_TUPLE should resolve to the local library path
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * architecture tuple systemd is built for, according to the Debian
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * tuple list:
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen *
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * https://wiki.debian.org/Multiarch/Tuples
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen *
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * This is used in library search paths that should understand
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen * Debian's paths on all distributions.
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen */
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#if defined(__x86_64__)
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_X86_64
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define LIB_ARCH_TUPLE "x86_64-linux-gnu"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#elif defined(__i386__)
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_X86
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define LIB_ARCH_TUPLE "i386-linux-gnu"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#elif defined(__powerpc64__)
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# if defined(WORDS_BIGENDIAN)
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_PPC64
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define LIB_ARCH_TUPLE "ppc64-linux-gnu"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# else
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_PPC64_LE
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# error "Missing LIB_ARCH_TUPLE for PPC64LE"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# endif
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen#elif defined(__powerpc__)
f168c27313e4d7b0aabee037dc9c78a5799f0597Thomas Hindoe Paaboel Andersen# if defined(WORDS_BIGENDIAN)
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_PPC
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define LIB_ARCH_TUPLE "powerpc-linux-gnu"
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# else
97b5f608182773d7ef9ca18913085b3a3eccd943Thomas Hindoe Paaboel Andersen# define native_architecture() ARCHITECTURE_PPC_LE
# error "Missing LIB_ARCH_TUPLE for PPCLE"
# endif
#elif defined(__ia64__)
# define native_architecture() ARCHITECTURE_IA64
# define LIB_ARCH_TUPLE "ia64-linux-gnu"
#elif defined(__hppa64__)
# define native_architecture() ARCHITECTURE_PARISC64
# error "Missing LIB_ARCH_TUPLE for HPPA64"
#elif defined(__hppa__)
# define native_architecture() ARCHITECTURE_PARISC
# define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
#elif defined(__s390x__)
# define native_architecture() ARCHITECTURE_S390X
# define LIB_ARCH_TUPLE "s390x-linux-gnu"
#elif defined(__s390__)
# define native_architecture() ARCHITECTURE_S390
# define LIB_ARCH_TUPLE "s390-linux-gnu"
#elif defined(__sparc64__)
# define native_architecture() ARCHITECTURE_SPARC64
# define LIB_ARCH_TUPLE "sparc64-linux-gnu"
#elif defined(__sparc__)
# define native_architecture() ARCHITECTURE_SPARC
# define LIB_ARCH_TUPLE "sparc-linux-gnu"
#elif defined(__mips64__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_MIPS64
# error "Missing LIB_ARCH_TUPLE for MIPS64"
# else
# define native_architecture() ARCHITECTURE_MIPS64_LE
# error "Missing LIB_ARCH_TUPLE for MIPS64_LE"
# endif
#elif defined(__mips__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_MIPS
# define LIB_ARCH_TUPLE "mips-linux-gnu"
# else
# define native_architecture() ARCHITECTURE_MIPS_LE
# define LIB_ARCH_TUPLE "mipsel-linux-gnu"
#endif
#elif defined(__alpha__)
# define native_architecture() ARCHITECTURE_ALPHA
# define LIB_ARCH_TUPLE "alpha-linux-gnu"
#elif defined(__aarch64__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_ARM64_BE
# define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
# else
# define native_architecture() ARCHITECTURE_ARM64
# define LIB_ARCH_TUPLE "aarch64-linux-gnu"
# endif
#elif defined(__arm__)
# if defined(WORDS_BIGENDIAN)
# define native_architecture() ARCHITECTURE_ARM_BE
# if defined(__ARM_PCS_VFP)
# define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
# else
# define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
# endif
# else
# define native_architecture() ARCHITECTURE_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 LIB_ARCH_TUPLE for SH64"
#elif defined(__sh__)
# define native_architecture() ARCHITECTURE_SH
# define LIB_ARCH_TUPLE "sh4-linux-gnu"
#elif defined(__m68k__)
# define native_architecture() ARCHITECTURE_M68K
# define LIB_ARCH_TUPLE "m68k-linux-gnu"
#elif defined(__tilegx__)
# define native_architecture() ARCHITECTURE_TILEGX
# error "Missing LIB_ARCH_TUPLE for TILEGX"
#elif defined(__cris__)
# define native_architecture() ARCHITECTURE_CRIS
# error "Missing LIB_ARCH_TUPLE for CRIS"
#else
#error "Please register your architecture here!"
#endif
const char *architecture_to_string(Architecture a) _const_;
Architecture architecture_from_string(const char *s) _pure_;