xref: /illumos-gate/usr/src/tools/smatch/src/machine.h (revision 31ad075e)
1c85f09ccSJohn Levon #ifndef MACHINE_H
2c85f09ccSJohn Levon #define MACHINE_H
3c85f09ccSJohn Levon 
4c85f09ccSJohn Levon #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
5c85f09ccSJohn Levon #define ARCH_BIG_ENDIAN 1
6c85f09ccSJohn Levon #else
7c85f09ccSJohn Levon #define ARCH_BIG_ENDIAN 0
8c85f09ccSJohn Levon #endif
9c85f09ccSJohn Levon 
10c85f09ccSJohn Levon 
11c85f09ccSJohn Levon enum {
12c85f09ccSJohn Levon 	ARCH_LP32,
13c85f09ccSJohn Levon 	ARCH_X32,
14c85f09ccSJohn Levon 	ARCH_LP64,
15c85f09ccSJohn Levon 	ARCH_LLP64,
16c85f09ccSJohn Levon };
17c85f09ccSJohn Levon 
18c85f09ccSJohn Levon #ifdef __LP64__
19c85f09ccSJohn Levon #define ARCH_M64_DEFAULT ARCH_LP64
20c85f09ccSJohn Levon #elif defined(__x86_64__) || defined(__x86_64)
21c85f09ccSJohn Levon #define ARCH_M64_DEFAULT ARCH_X32
22c85f09ccSJohn Levon #else
23c85f09ccSJohn Levon #define ARCH_M64_DEFAULT ARCH_LP32
24c85f09ccSJohn Levon #endif
25c85f09ccSJohn Levon 
26c85f09ccSJohn Levon 
27c85f09ccSJohn Levon enum machine {
28c85f09ccSJohn Levon 	MACH_ARM,
29c85f09ccSJohn Levon 	MACH_ARM64,
30c85f09ccSJohn Levon 	MACH_I386,
31c85f09ccSJohn Levon 	MACH_X86_64,
32c85f09ccSJohn Levon 	MACH_MIPS32,
33c85f09ccSJohn Levon 	MACH_MIPS64,
34c85f09ccSJohn Levon 	MACH_PPC32,
35c85f09ccSJohn Levon 	MACH_PPC64,
36c85f09ccSJohn Levon 	MACH_RISCV32,
37c85f09ccSJohn Levon 	MACH_RISCV64,
38c85f09ccSJohn Levon 	MACH_SPARC32,
39c85f09ccSJohn Levon 	MACH_SPARC64,
40c85f09ccSJohn Levon 	MACH_M68K,
41c85f09ccSJohn Levon 	MACH_S390X,
42c85f09ccSJohn Levon 	MACH_UNKNOWN
43c85f09ccSJohn Levon };
44c85f09ccSJohn Levon 
45c85f09ccSJohn Levon #if defined(__aarch64__)
46c85f09ccSJohn Levon #define MACH_NATIVE	MACH_ARM64
47c85f09ccSJohn Levon #elif defined(__arm__)
48c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_ARM
49c85f09ccSJohn Levon #elif defined(__x86_64__) || defined(__x86_64)
50c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_X86_64
51c85f09ccSJohn Levon #elif defined(__i386__) || defined(__i386)
52c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_I386
53c85f09ccSJohn Levon #elif defined(__mips64__) || (defined(__mips) && __mips == 64)
54c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_MIPS64
55c85f09ccSJohn Levon #elif defined(__mips__) || defined(__mips)
56c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_MIPS32
57c85f09ccSJohn Levon #elif defined(__powerpc64__) || defined(__ppc64__)
58c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_PPC64
59c85f09ccSJohn Levon #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__)
60c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_PPC32
61c85f09ccSJohn Levon #elif defined(__riscv) && (__riscv_xlen == 64)
62c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_RISCV64
63c85f09ccSJohn Levon #elif defined(__riscv) && (__riscv_xlen == 32)
64c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_RISCV32
65*31ad075eSJohn Levon #elif defined(__sparc_v9__) || defined(__sparcv9)
66c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_SPARC64
67c85f09ccSJohn Levon #elif defined(__sparc__) || defined(__sparc)
68c85f09ccSJohn Levon #define	MACH_NATIVE	MACH_SPARC32
69c85f09ccSJohn Levon #elif defined(__m68k__)
70c85f09ccSJohn Levon #define MACH_NATIVE	MACH_M68K
71c85f09ccSJohn Levon #elif defined(__s390x__) || defined(__zarch__)
72c85f09ccSJohn Levon #define MACH_NATIVE	MACH_S390X
73c85f09ccSJohn Levon #else
74c85f09ccSJohn Levon #define MACH_NATIVE	MACH_UNKNOWN
75c85f09ccSJohn Levon #endif
76c85f09ccSJohn Levon 
77c85f09ccSJohn Levon #if defined(__CHAR_UNSIGNED__)
78c85f09ccSJohn Levon #define	UNSIGNED_CHAR	1
79c85f09ccSJohn Levon #else
80c85f09ccSJohn Levon #define UNSIGNED_CHAR	0
81c85f09ccSJohn Levon #endif
82c85f09ccSJohn Levon 
83c85f09ccSJohn Levon #endif
84