architecture.h revision ae0e60fbbc28990617964204ea925a1ef8f42262
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#pragma once
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering/***
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering This file is part of systemd.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Copyright 2014 Lennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is free software; you can redistribute it and/or modify it
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering under the terms of the GNU Lesser General Public License as published by
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering (at your option) any later version.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is distributed in the hope that it will be useful, but
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Lesser General Public License for more details.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering You should have received a copy of the GNU Lesser General Public License
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering***/
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#include "util.h"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringtypedef enum Architecture {
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_X86 = 0,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_X86_64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PPC,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PPC_LE,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PPC64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PPC64_LE,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_IA64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PARISC,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_PARISC64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_S390,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_S390X,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_SPARC,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_SPARC64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_MIPS,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_MIPS64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_ALPHA,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_ARM,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_ARM_BE,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_ARM64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_ARM64_BE,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_SH,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_SH64,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering ARCHITECTURE_M68K,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering _ARCHITECTURE_MAX,
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering _ARCHITECTURE_INVALID = -1
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering} Architecture;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart PoetteringArchitecture uname_architecture(void);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#if defined(__x86_64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_X86_64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__i386__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_X86
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__powerpc64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# if defined(WORDS_BIGENDIAN)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PPC64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# else
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PPC64_LE
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# endif
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__powerpc__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# if defined(WORDS_BIGENDIAN)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PPC
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# else
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PPC_LE
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# endif
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__ia64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_IA64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__hppa64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PARISC64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__hppa__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_PARISC
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__s390x__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_S390X
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__s390__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_S390
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__sparc64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_SPARC64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__sparc__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_SPARC
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__mips64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_MIPS64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__mips__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_MIPS
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__alpha__)
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering# define native_architecture() ARCHITECTURE_ALPHA
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering#elif defined(__aarch64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# if defined(WORDS_BIGENDIAN)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_ARM64_BE
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# else
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_ARM64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# endif
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__arm__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# if defined(WORDS_BIGENDIAN)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_ARM_BE
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# else
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_ARM
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# endif
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__sh64__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_SH64
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__sh__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_SH
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#elif defined(__m68k__)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# define native_architecture() ARCHITECTURE_M68K
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#else
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#error "Please register your architecture here!"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#endif
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poetteringconst char *architecture_to_string(Architecture a) _const_;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart PoetteringArchitecture architecture_from_string(const char *s) _pure_;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering