1*c42dbd0eSchristos /* Copyright (C) 2021 Free Software Foundation, Inc. 2*c42dbd0eSchristos Contributed by Oracle. 3*c42dbd0eSchristos 4*c42dbd0eSchristos This file is part of GNU Binutils. 5*c42dbd0eSchristos 6*c42dbd0eSchristos This program is free software; you can redistribute it and/or modify 7*c42dbd0eSchristos it under the terms of the GNU General Public License as published by 8*c42dbd0eSchristos the Free Software Foundation; either version 3, or (at your option) 9*c42dbd0eSchristos any later version. 10*c42dbd0eSchristos 11*c42dbd0eSchristos This program is distributed in the hope that it will be useful, 12*c42dbd0eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 13*c42dbd0eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*c42dbd0eSchristos GNU General Public License for more details. 15*c42dbd0eSchristos 16*c42dbd0eSchristos You should have received a copy of the GNU General Public License 17*c42dbd0eSchristos along with this program; if not, write to the Free Software 18*c42dbd0eSchristos Foundation, 51 Franklin Street - Fifth Floor, Boston, 19*c42dbd0eSchristos MA 02110-1301, USA. */ 20*c42dbd0eSchristos 21*c42dbd0eSchristos #ifndef _GP_DEFS_H_ 22*c42dbd0eSchristos #define _GP_DEFS_H_ 23*c42dbd0eSchristos 24*c42dbd0eSchristos /* Define the ARCH and WSIZE predicates */ 25*c42dbd0eSchristos /* 26*c42dbd0eSchristos * The way we define and use predicates is similar to the 27*c42dbd0eSchristos * standard #assert with one important exception: 28*c42dbd0eSchristos * if an argument of a predicate is not known the result 29*c42dbd0eSchristos * is 'false' and we want a compile time error to avoid 30*c42dbd0eSchristos * silent results from typos like ARCH(INTEL), COMPILER(gnu), 31*c42dbd0eSchristos * etc. 32*c42dbd0eSchristos */ 33*c42dbd0eSchristos #define ARCH(x) TOK_A_##x(ARCH) 34*c42dbd0eSchristos #define TOK_A_Aarch64(x) x##_Aarch64 35*c42dbd0eSchristos #define TOK_A_SPARC(x) x##_SPARC 36*c42dbd0eSchristos #define TOK_A_Intel(x) x##_Intel 37*c42dbd0eSchristos 38*c42dbd0eSchristos #define WSIZE(x) TOK_W_##x(WSIZE) 39*c42dbd0eSchristos #define TOK_W_32(x) x##_32 40*c42dbd0eSchristos #define TOK_W_64(x) x##_64 41*c42dbd0eSchristos 42*c42dbd0eSchristos #if defined(sparc) || defined(__sparcv9) 43*c42dbd0eSchristos #define ARCH_SPARC 1 44*c42dbd0eSchristos #elif defined(__i386__) || defined(__x86_64) 45*c42dbd0eSchristos #define ARCH_Intel 1 46*c42dbd0eSchristos #elif defined(__aarch64__) 47*c42dbd0eSchristos #define ARCH_Aarch64 1 48*c42dbd0eSchristos #else 49*c42dbd0eSchristos #error "Undefined platform" 50*c42dbd0eSchristos #endif 51*c42dbd0eSchristos 52*c42dbd0eSchristos #if defined(__sparcv9) || defined(__x86_64) || defined(__aarch64__) 53*c42dbd0eSchristos #define WSIZE_64 1 54*c42dbd0eSchristos #else 55*c42dbd0eSchristos #define WSIZE_32 1 56*c42dbd0eSchristos #endif 57*c42dbd0eSchristos 58*c42dbd0eSchristos #ifndef ATTRIBUTE_FALLTHROUGH 59*c42dbd0eSchristos # if (GCC_VERSION >= 7000) 60*c42dbd0eSchristos # define ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) 61*c42dbd0eSchristos # else 62*c42dbd0eSchristos # define ATTRIBUTE_FALLTHROUGH /* Fall through */ 63*c42dbd0eSchristos # endif 64*c42dbd0eSchristos #endif 65*c42dbd0eSchristos 66*c42dbd0eSchristos #endif 67