1 /*
2  * Copyright 2011-2012 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Arx Libertatis is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ARX_PLATFORM_ARCHITECTURE_H
21 #define ARX_PLATFORM_ARCHITECTURE_H
22 
23 #define ARX_ARCH_UNKNOWN          0
24 #define ARX_ARCH_X86_64           1
25 #define ARX_ARCH_IA64             2
26 #define ARX_ARCH_X86              3
27 #define ARX_ARCH_ARM              4
28 #define ARX_ARCH_ALPHA            5
29 #define ARX_ARCH_M68K             6
30 #define ARX_ARCH_MIPS             7
31 #define ARX_ARCH_POWERPC          8
32 #define ARX_ARCH_SPARC            9
33 
34 #define ARX_ARCH_NAME_UNKNOWN     ""
35 #define ARX_ARCH_NAME_X86_64      "x86_64"
36 #define ARX_ARCH_NAME_IA64        "ia64"
37 #define ARX_ARCH_NAME_X86         "x86"
38 #define ARX_ARCH_NAME_ARM         "arm"
39 #define ARX_ARCH_NAME_ALPHA       "alpha"
40 #define ARX_ARCH_NAME_M68K        "m68k"
41 #define ARX_ARCH_NAME_MIPS        "mips"
42 #define ARX_ARCH_NAME_POWERPC     "powerpc"
43 #define ARX_ARCH_NAME_SPARC       "sparc"
44 
45 // Checks are shamelessly copied from
46 // https://sourceforge.net/apps/mediawiki/predef/index.php?title=Architectures
47 
48 #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) \
49       || defined(__x86_64) || defined(_M_X64)
50 #define ARX_ARCH ARX_ARCH_X86_64
51 #define ARX_ARCH_NAME ARX_ARCH_NAME_X86_64
52 
53 #elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || defined(__ia64) \
54       || defined(_M_IA64) || defined(__itanium__)
55 #define ARX_ARCH ARX_ARCH_IA64
56 #define ARX_ARCH_NAME ARX_ARCH_NAME_IA64
57 
58 #elif defined(i386) || defined(__i386__) || defined(__i386) || defined(__IA32__) \
59       || defined(_M_IX86) || defined(__X86__) || defined(_X86_) \
60       || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__)
61 #define ARX_ARCH ARX_ARCH_X86
62 #define ARX_ARCH_NAME ARX_ARCH_NAME_X86
63 
64 #elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
65       || defined(__TARGET_ARCH_THUMB) || defined(_ARM)
66 #define ARX_ARCH ARX_ARCH_ARM
67 #define ARX_ARCH_NAME ARX_ARCH_NAME_ARM
68 
69 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
70 #define ARX_ARCH ARX_ARCH_ALPHA
71 #define ARX_ARCH_NAME ARX_ARCH_NAME_ALPHA
72 
73 #elif defined(__m68k__) || defined(M68000) || defined(__MC68K__)
74 #define ARX_ARCH ARX_ARCH_M68K
75 #define ARX_ARCH_NAME ARX_ARCH_NAME_M68K
76 
77 #elif defined(__mips__) || defined(mips) || defined(__mips) || defined(__MIPS__)
78 #define ARX_ARCH ARX_ARCH_MIPS
79 #define ARX_ARCH_NAME ARX_ARCH_NAME_MIPS
80 
81 #elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) \
82       ||defined(__ppc__) || defined(_M_PPC) || defined(_ARCH_PPC)
83 #define ARX_ARCH ARX_ARCH_POWERPC
84 #define ARX_ARCH_NAME ARX_ARCH_NAME_POWERPC
85 
86 #elif defined(__sparc__) || defined(__sparc)
87 #define ARX_ARCH ARX_ARCH_SPARC
88 #define ARX_ARCH_NAME ARX_ARCH_NAME_SPARC
89 
90 #else
91 #define ARX_ARCH ARX_ARCH_UNKNOWN
92 #define ARX_ARCH_NAME ARX_ARCH_NAME_UNKNOWN
93 
94 #endif
95 
96 #endif // ARX_PLATFORM_ARCHITECTURE_H
97