1 /************************************************************************** 2 * 3 * Copyright 2008 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28 /** 29 * @file 30 * Gallium configuration defines. 31 * 32 * This header file sets several defines based on the compiler, processor 33 * architecture, and operating system being used. These defines should be used 34 * throughout the code to facilitate porting to new platforms. It is likely that 35 * this file is auto-generated by an autoconf-like tool at some point, as some 36 * things cannot be determined by pre-defined environment alone. 37 * 38 * See also: 39 * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html 40 * - echo | gcc -dM -E - | sort 41 * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx 42 * 43 * @author José Fonseca <[email protected]> 44 */ 45 46 #ifndef UTIL_DETECT_ARCH_H_ 47 #define UTIL_DETECT_ARCH_H_ 48 49 #include <limits.h> 50 51 #include "util/detect_cc.h" 52 53 /* 54 * Processor architecture 55 */ 56 57 #if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */ 58 #define DETECT_ARCH_X86 1 59 #endif 60 61 #if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ || defined(__x86_64) /* Sun cc */ 62 #define DETECT_ARCH_X86_64 1 63 #endif 64 65 #if DETECT_ARCH_X86 || DETECT_ARCH_X86_64 66 #if DETECT_CC_GCC && !defined(__SSE2__) 67 /* #warning SSE2 support requires -msse -msse2 compiler options */ 68 #else 69 #define DETECT_ARCH_SSE 1 70 #endif 71 #endif 72 73 #if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__) || defined(__PPC64__) 74 #define DETECT_ARCH_PPC 1 75 #if defined(__ppc64__) || defined(__PPC64__) 76 #define DETECT_ARCH_PPC_64 1 77 #endif 78 #endif 79 80 #if defined(__s390x__) 81 #define DETECT_ARCH_S390 1 82 #endif 83 84 #if defined(__arm__) 85 #define DETECT_ARCH_ARM 1 86 #endif 87 88 #if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) 89 #define DETECT_ARCH_AARCH64 1 90 #endif 91 92 #if defined(__mips64) && defined(__LP64__) 93 #define DETECT_ARCH_MIPS64 1 94 #endif 95 96 #if defined(__mips__) 97 #define DETECT_ARCH_MIPS 1 98 #endif 99 100 #if defined(__hppa__) 101 #define DETECT_ARCH_HPPA 1 102 #endif 103 104 #if defined(__riscv) 105 #define DETECT_ARCH_RISCV 1 106 #if __riscv_xlen == 64 107 #define DETECT_ARCH_RISCV64 1 108 #elif __riscv_xlen == 32 109 #define DETECT_ARCH_RISCV32 1 110 #else 111 #error "detect_arch: unknown target riscv xlen" 112 #endif 113 #endif 114 115 #if defined(__loongarch__) 116 #ifdef __loongarch_lp64 117 #define DETECT_ARCH_LOONGARCH64 1 118 #else 119 #error "detect_arch: unknown target loongarch base ABI type" 120 #endif 121 #endif 122 123 #ifndef DETECT_ARCH_X86 124 #define DETECT_ARCH_X86 0 125 #endif 126 127 #ifndef DETECT_ARCH_X86_64 128 #define DETECT_ARCH_X86_64 0 129 #endif 130 131 #ifndef DETECT_ARCH_SSE 132 #define DETECT_ARCH_SSE 0 133 #endif 134 135 #ifndef DETECT_ARCH_PPC 136 #define DETECT_ARCH_PPC 0 137 #endif 138 139 #ifndef DETECT_ARCH_PPC_64 140 #define DETECT_ARCH_PPC_64 0 141 #endif 142 143 #ifndef DETECT_ARCH_S390 144 #define DETECT_ARCH_S390 0 145 #endif 146 147 #ifndef DETECT_ARCH_ARM 148 #define DETECT_ARCH_ARM 0 149 #endif 150 151 #ifndef DETECT_ARCH_AARCH64 152 #define DETECT_ARCH_AARCH64 0 153 #endif 154 155 #ifndef DETECT_ARCH_MIPS64 156 #define DETECT_ARCH_MIPS64 0 157 #endif 158 159 #ifndef DETECT_ARCH_MIPS 160 #define DETECT_ARCH_MIPS 0 161 #endif 162 163 #ifndef DETECT_ARCH_HPPA 164 #define DETECT_ARCH_HPPA 0 165 #endif 166 167 #ifndef DETECT_ARCH_RISCV 168 #define DETECT_ARCH_RISCV 0 169 #endif 170 171 #ifndef DETECT_ARCH_RISCV32 172 #define DETECT_ARCH_RISCV32 0 173 #endif 174 175 #ifndef DETECT_ARCH_RISCV64 176 #define DETECT_ARCH_RISCV64 0 177 #endif 178 179 #ifndef DETECT_ARCH_LOONGARCH64 180 #define DETECT_ARCH_LOONGARCH64 0 181 #endif 182 183 #endif /* UTIL_DETECT_ARCH_H_ */ 184