1 #ifndef MACHINE_H 2 #define MACHINE_H 3 4 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 5 #define ARCH_BIG_ENDIAN 1 6 #else 7 #define ARCH_BIG_ENDIAN 0 8 #endif 9 10 11 enum bitness { 12 ARCH_LP32, 13 ARCH_X32, 14 ARCH_LP64, 15 ARCH_LLP64, 16 }; 17 18 #ifdef __LP64__ 19 #define ARCH_M64_DEFAULT ARCH_LP64 20 #elif defined(__x86_64__) || defined(__x86_64) 21 #define ARCH_M64_DEFAULT ARCH_X32 22 #else 23 #define ARCH_M64_DEFAULT ARCH_LP32 24 #endif 25 26 27 enum machine { 28 MACH_ARM, MACH_ARM64, 29 MACH_I386, MACH_X86_64, 30 MACH_MIPS32, MACH_MIPS64, 31 MACH_PPC32, MACH_PPC64, 32 MACH_RISCV32, MACH_RISCV64, 33 MACH_SPARC32, MACH_SPARC64, 34 MACH_S390, MACH_S390X, 35 MACH_ALPHA, 36 MACH_BFIN, 37 MACH_H8300, 38 MACH_M68K, 39 MACH_MICROBLAZE, 40 MACH_NDS32, 41 MACH_NIOS2, 42 MACH_OPENRISC, 43 MACH_SH, 44 MACH_XTENSA, 45 MACH_UNKNOWN 46 }; 47 48 #if defined(__aarch64__) 49 #define MACH_NATIVE MACH_ARM64 50 #elif defined(__alpha__) || defined(__alpha) 51 #define MACH_NATIVE MACH_ALPHA 52 #elif defined(__arm__) 53 #define MACH_NATIVE MACH_ARM 54 #elif defined(__x86_64__) || defined(__x86_64) 55 #define MACH_NATIVE MACH_X86_64 56 #elif defined(__i386__) || defined(__i386) 57 #define MACH_NATIVE MACH_I386 58 #elif defined(__mips64__) || (defined(__mips) && __mips == 64) 59 #define MACH_NATIVE MACH_MIPS64 60 #elif defined(__mips__) || defined(__mips) 61 #define MACH_NATIVE MACH_MIPS32 62 #elif defined(__powerpc64__) || defined(__ppc64__) 63 #define MACH_NATIVE MACH_PPC64 64 #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) 65 #define MACH_NATIVE MACH_PPC32 66 #elif defined(__riscv) && (__riscv_xlen == 64) 67 #define MACH_NATIVE MACH_RISCV64 68 #elif defined(__riscv) && (__riscv_xlen == 32) 69 #define MACH_NATIVE MACH_RISCV32 70 #elif defined(__sparc_v9__) || defined(__sparcv9) 71 #define MACH_NATIVE MACH_SPARC64 72 #elif defined(__sparc__) || defined(__sparc) 73 #define MACH_NATIVE MACH_SPARC32 74 #elif defined(__m68k__) 75 #define MACH_NATIVE MACH_M68K 76 #elif defined(__s390x__) || defined(__zarch__) 77 #define MACH_NATIVE MACH_S390X 78 #elif defined(__s390__) 79 #define MACH_NATIVE MACH_S390 80 #else 81 #define MACH_NATIVE MACH_UNKNOWN 82 #endif 83 84 85 enum fp_abi { 86 FP_ABI_HARD, 87 FP_ABI_SOFT, 88 FP_ABI_HYBRID, 89 }; 90 91 #if defined(__ARM_PCS_VFP) 92 #define FP_ABI_NATIVE FP_ABI_HARD 93 #elif defined(__ARM_PCS) && !defined(__SOFTFP__) 94 #define FP_ABI_NATIVE FP_ABI_HYBRID 95 #else 96 #define FP_ABI_NATIVE FP_ABI_SOFT 97 #endif 98 99 100 enum { 101 OS_UNKNOWN, 102 OS_NONE, 103 OS_UNIX, 104 OS_CYGWIN, 105 OS_DARWIN, 106 OS_FREEBSD, 107 OS_LINUX, 108 OS_NETBSD, 109 OS_OPENBSD, 110 OS_SUNOS, 111 }; 112 113 #if defined(__CYGWIN__) 114 #define OS_NATIVE OS_CYGWIN 115 #elif defined(__APPLE__) 116 #define OS_NATIVE OS_DARWIN 117 #elif defined(__FreeBSD__) 118 #define OS_NATIVE OS_FREEBSD 119 #elif defined(__linux__) || defined(__linux) 120 #define OS_NATIVE OS_LINUX 121 #elif defined(__NetBSD__) 122 #define OS_NATIVE OS_NETBSD 123 #elif defined(__OpenBSD__) 124 #define OS_NATIVE OS_OPENBSD 125 #elif defined(__sun__) || defined(__sun) 126 #define OS_NATIVE OS_SUNOS 127 #elif defined(__unix__) || defined(__unix) 128 #define OS_NATIVE OS_UNIX 129 #else 130 #define OS_NATIVE OS_UNKNOWN 131 #endif 132 133 #endif 134