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