architecture.c revision 592fd144ae313855f48d0ca52a103013b41e5d59
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt This file is part of systemd.
7bd8e95d44977833d0de3fc4e893eb3bc84351d6Patrik Flykt Copyright 2014 Lennart Poettering
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is free software; you can redistribute it and/or modify it
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt under the terms of the GNU Lesser General Public License as published by
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt the Free Software Foundation; either version 2.1 of the License, or
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt (at your option) any later version.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is distributed in the hope that it will be useful, but
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt WITHOUT ANY WARRANTY; without even the implied warranty of
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Lesser General Public License for more details.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt You should have received a copy of the GNU Lesser General Public License
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt along with systemd; If not, see <http://www.gnu.org/licenses/>.
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Return a sanitized enum identifying the architecture we are
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * running on. This is based on uname(), and the user may
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * hence control what this returns by using
3df3e884ae1237ef0d4d23b0e80f4ffda95ac135Ronny Chevalier * personality(). This puts the user in control on systems
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * that can run binaries of multiple architectures.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * We do not translate the string returned by uname()
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * 1:1. Instead we try to clean it up and break down the
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * confusion on x86 and arm in particular.
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen * We do not try to distuingish CPUs not CPU features, but
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * actual architectures, i.e. that have genuinely different
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt static const struct {
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt#elif defined(__powerpc__) || defined(__powerpc64__)
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt#elif defined(__sparc__) || defined(__sparc64__)
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#error "Please register your architecture here!"
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams assert_not_reached("Couldn't identify architecture. You need to patch systemd.");
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williamsstatic const char *const architecture_table[_ARCHITECTURE_MAX] = {