1 /* 2 * Copyright 2009-2010, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CONFIG_HAIKU_CONFIG_H 6 #define _CONFIG_HAIKU_CONFIG_H 7 8 9 /* Determine the architecture and define macros for some fundamental 10 properties: 11 __HAIKU_ARCH - short name of the architecture (used in paths) 12 __HAIKU_ARCH_ABI - name of ABI (as in package architecture) 13 __HAIKU_ARCH_<arch> - defined to 1 for the respective architecture 14 __HAIKU_ARCH_BITS - defined to 32/64 on 32/64 bit architectures 15 (defaults to 32) 16 __HAIKU_ARCH_PHYSICAL_BITS - defined to 32/64 on architectures with 32/64 17 (defaults to __HAIKU_ARCH_BITS) 18 __HAIKU_BIG_ENDIAN - defined to 1 on big endian architectures 19 (defaults to undefined) 20 */ 21 #if defined(__i386__) 22 # define __HAIKU_ARCH x86 23 # if __GNUC__ == 2 24 # define __HAIKU_ARCH_ABI "x86_gcc2" 25 # else 26 # define __HAIKU_ARCH_ABI "x86" 27 # endif 28 # define __HAIKU_ARCH_X86 1 29 # define __HAIKU_ARCH_PHYSICAL_BITS 64 30 #elif defined(__x86_64__) 31 # define __HAIKU_ARCH x86_64 32 # define __HAIKU_ARCH_ABI "x86_64" 33 # define __HAIKU_ARCH_X86_64 1 34 # define __HAIKU_ARCH_BITS 64 35 #elif defined(__POWERPC__) 36 # define __HAIKU_ARCH ppc 37 # define __HAIKU_ARCH_ABI "ppc" 38 # define __HAIKU_ARCH_PPC 1 39 # define __HAIKU_ARCH_PHYSICAL_BITS 64 40 # define __HAIKU_BIG_ENDIAN 1 41 #elif defined(__M68K__) 42 # define __HAIKU_ARCH m68k 43 # define __HAIKU_ARCH_ABI "m68k" 44 # define __HAIKU_ARCH_M68K 1 45 # define __HAIKU_BIG_ENDIAN 1 46 #elif defined(__MIPSEL__) 47 # define __HAIKU_ARCH mipsel 48 # define __HAIKU_ARCH_ABI "mipsel" 49 # define __HAIKU_ARCH_MIPSEL 1 50 #elif defined(__ARMEL__) || defined(__arm__) 51 # define __HAIKU_ARCH arm 52 # define __HAIKU_ARCH_ABI "arm" 53 # define __HAIKU_ARCH_ARM 1 54 #elif defined(__ARMEB__) 55 # define __HAIKU_ARCH armeb 56 # define __HAIKU_ARCH_ABI "armeb" 57 # define __HAIKU_ARCH_ARM 1 58 # define __HAIKU_BIG_ENDIAN 1 59 #elif defined(__aarch64__) || defined(__arm64__) 60 # define __HAIKU_ARCH arm64 61 # define __HAIKU_ARCH_ABI "arm64" 62 # define __HAIKU_ARCH_ARM64 1 63 # define __HAIKU_ARCH_BITS 64 64 #elif (defined(__riscv) && __riscv_xlen == 32) 65 # define __HAIKU_ARCH riscv32 66 # define __HAIKU_ARCH_ABI "riscv32" 67 # define __HAIKU_ARCH_RISCV32 1 68 # define __HAIKU_ARCH_BITS 32 69 #elif (defined(__riscv) && __riscv_xlen == 64) 70 # define __HAIKU_ARCH riscv64 71 # define __HAIKU_ARCH_ABI "riscv64" 72 # define __HAIKU_ARCH_RISCV64 1 73 # define __HAIKU_ARCH_BITS 64 74 #elif (defined(__riscv) && __riscv_xlen == 128) 75 # define __HAIKU_ARCH riscv128 76 # define __HAIKU_ARCH_ABI "riscv128" 77 # define __HAIKU_ARCH_RISCV128 1 78 # define __HAIKU_ARCH_BITS 128 79 #elif defined(__sparc64__) 80 # define __HAIKU_ARCH sparc64 81 # define __HAIKU_ARCH_ABI "sparc" 82 # define __HAIKU_ARCH_SPARC 1 83 # define __HAIKU_ARCH_PHYSICAL_BITS 64 84 # define __HAIKU_BIG_ENDIAN 1 85 # define __HAIKU_ARCH_BITS 64 86 #else 87 # error Unsupported architecture! 88 #endif 89 90 /* implied properties: 91 __HAIKU_ARCH_{32,64}_BIT - defined to 1 on 32/64 bit architectures, i.e. 92 using 32/64 bit virtual addresses 93 __HAIKU_ARCH_PHYSICAL_BITS - defined to 32/64 on architectures with 32/64 94 bit physical addresses 95 __HAIKU_ARCH_PHYSICAL_{32,64}_BIT - defined to 1 on architectures using 64 96 bit physical addresses 97 __HAIKU_BIG_ENDIAN - defined to 1 on big endian architectures 98 */ 99 100 /* bitness */ 101 #ifndef __HAIKU_ARCH_BITS 102 # define __HAIKU_ARCH_BITS 32 103 #endif 104 105 #if __HAIKU_ARCH_BITS == 32 106 # define __HAIKU_ARCH_32_BIT 1 107 #elif __HAIKU_ARCH_BITS == 64 108 # define __HAIKU_ARCH_64_BIT 1 109 #else 110 # error Unsupported bitness! 111 #endif 112 113 /* physical bitness */ 114 #ifndef __HAIKU_ARCH_PHYSICAL_BITS 115 # define __HAIKU_ARCH_PHYSICAL_BITS __HAIKU_ARCH_BITS 116 #endif 117 118 #if __HAIKU_ARCH_PHYSICAL_BITS == 32 119 # define __HAIKU_ARCH_PHYSICAL_32_BIT 1 120 #elif __HAIKU_ARCH_PHYSICAL_BITS == 64 121 # define __HAIKU_ARCH_PHYSICAL_64_BIT 1 122 #else 123 # error Unsupported physical bitness! 124 #endif 125 126 /* endianess */ 127 #ifndef __HAIKU_BIG_ENDIAN 128 # define __HAIKU_LITTLE_ENDIAN 1 129 #endif 130 131 /* architecture specific include macros */ 132 #define __HAIKU_ARCH_HEADER(header) <arch/__HAIKU_ARCH/header> 133 #define __HAIKU_SUBDIR_ARCH_HEADER(subdir, header) \ 134 <subdir/arch/__HAIKU_ARCH/header> 135 136 /* BeOS R5 binary compatibility (gcc 2 on x86) */ 137 #if defined(__HAIKU_ARCH_X86) && __GNUC__ == 2 138 # define __HAIKU_BEOS_COMPATIBLE 1 139 #endif 140 141 /* BeOS R5 compatible types */ 142 #if defined(__HAIKU_ARCH_X86) 143 /* TODO: This should be "#ifdef __HAIKU_BEOS_COMPATIBLE", but this will 144 break all gcc 4 C++ optional packages. I.e. switch that at a suitable 145 time. 146 */ 147 # define __HAIKU_BEOS_COMPATIBLE_TYPES 1 148 #endif 149 150 151 #endif /* _CONFIG_HAIKU_CONFIG_H */ 152