DDraceNetwork Documentation
Loading...
Searching...
No Matches
detect.h
Go to the documentation of this file.
1
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2
/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
#ifndef BASE_DETECT_H
4
#define BASE_DETECT_H
5
6
/*
7
this file detected the family, platform and architecture
8
to compile for.
9
*/
10
11
/* platforms */
12
13
/* windows Family */
14
#if defined(WIN64) || defined(_WIN64)
15
/* Hmm, is this IA64 or x86-64? */
16
#define CONF_FAMILY_WINDOWS 1
17
#define CONF_FAMILY_STRING "windows"
18
#define CONF_PLATFORM_WIN64 1
19
#define PLATFORM_STRING "win64"
20
#elif defined(WIN32) || defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
21
#define CONF_FAMILY_WINDOWS 1
22
#define CONF_FAMILY_STRING "windows"
23
#define CONF_PLATFORM_WIN32 1
24
#define PLATFORM_STRING "win32"
25
#endif
26
27
/* unix family */
28
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
29
#define CONF_FAMILY_UNIX 1
30
#define CONF_FAMILY_STRING "unix"
31
#define CONF_PLATFORM_FREEBSD 1
32
#define PLATFORM_STRING "freebsd"
33
#endif
34
35
#if defined(__NetBSD__)
36
#define CONF_FAMILY_UNIX 1
37
#define CONF_FAMILY_STRING "unix"
38
#define CONF_PLATFORM_NETBSD 1
39
#define PLATFORM_STRING "netbsd"
40
#endif
41
42
#if defined(__OpenBSD__)
43
#define CONF_FAMILY_UNIX 1
44
#define CONF_FAMILY_STRING "unix"
45
#define CONF_PLATFORM_OPENBSD 1
46
#define PLATFORM_STRING "openbsd"
47
#endif
48
49
#if defined(__ANDROID__)
50
#define CONF_FAMILY_UNIX 1
51
#define CONF_FAMILY_STRING "unix"
52
#define CONF_PLATFORM_ANDROID 1
53
#define PLATFORM_STRING "android"
54
#define CONF_BACKEND_OPENGL_ES 1
55
#define CONF_BACKEND_OPENGL_ES3 1
56
#elif defined(__EMSCRIPTEN__)
57
#define CONF_FAMILY_UNIX 1
58
#define CONF_FAMILY_STRING "unix"
59
#define CONF_PLATFORM_EMSCRIPTEN 1
60
#define PLATFORM_STRING "emscripten"
61
#define CONF_BACKEND_OPENGL_ES3 1
62
#define CONF_BACKEND_OPENGL_ES 1
63
#elif defined(__LINUX__) || defined(__linux__)
64
#define CONF_FAMILY_UNIX 1
65
#define CONF_FAMILY_STRING "unix"
66
#define CONF_PLATFORM_LINUX 1
67
#define PLATFORM_STRING "linux"
68
#define CONF_BACKEND_OPENGL_ES3 1
69
#endif
70
71
#if defined(__GNU__) || defined(__gnu__)
72
#define CONF_FAMILY_UNIX 1
73
#define CONF_FAMILY_STRING "unix"
74
#define CONF_PLATFORM_HURD 1
75
#define PLATFORM_STRING "gnu"
76
#endif
77
78
#if defined(MACOSX) || defined(__APPLE__) || defined(__DARWIN__)
79
#define CONF_FAMILY_UNIX 1
80
#define CONF_FAMILY_STRING "unix"
81
#define CONF_PLATFORM_MACOS 1
82
#define PLATFORM_STRING "macos"
83
#endif
84
85
#if defined(__sun)
86
#define CONF_FAMILY_UNIX 1
87
#define CONF_FAMILY_STRING "unix"
88
#define CONF_PLATFORM_SOLARIS 1
89
#define PLATFORM_STRING "solaris"
90
#endif
91
92
/* beos family */
93
#if defined(__BeOS) || defined(__BEOS__)
94
#define CONF_FAMILY_BEOS 1
95
#define CONF_FAMILY_STRING "beos"
96
#define CONF_PLATFORM_BEOS 1
97
#define PLATFORM_STRING "beos"
98
#endif
99
100
#if defined(__HAIKU__)
101
#define CONF_FAMILY_UNIX 1
102
#define CONF_FAMILY_STRING "unix"
103
#define CONF_PLATFORM_HAIKU 1
104
#define PLATFORM_STRING "haiku"
105
#endif
106
107
/* use gcc endianness definitions when available */
108
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
109
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
110
#include <sys/endian.h>
111
#else
112
#include <endian.h>
113
#endif
114
115
#if __BYTE_ORDER == __LITTLE_ENDIAN
116
#define CONF_ARCH_ENDIAN_LITTLE 1
117
#elif __BYTE_ORDER == __BIG_ENDIAN
118
#define CONF_ARCH_ENDIAN_BIG 1
119
#endif
120
#endif
121
122
/* architectures */
123
#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(CONF_PLATFORM_WIN32)
124
#define CONF_ARCH_IA32 1
125
#define CONF_ARCH_STRING "ia32"
126
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
127
#define CONF_ARCH_ENDIAN_LITTLE 1
128
#endif
129
#endif
130
131
#if defined(__ia64__) || defined(_M_IA64)
132
#define CONF_ARCH_IA64 1
133
#define CONF_ARCH_STRING "ia64"
134
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
135
#define CONF_ARCH_ENDIAN_LITTLE 1
136
#endif
137
#endif
138
139
#if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
140
#define CONF_ARCH_AMD64 1
141
#define CONF_ARCH_STRING "amd64"
142
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
143
#define CONF_ARCH_ENDIAN_LITTLE 1
144
#endif
145
#endif
146
147
#if defined(__powerpc__) || defined(__ppc__)
148
#define CONF_ARCH_PPC 1
149
#define CONF_ARCH_STRING "ppc"
150
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
151
#define CONF_ARCH_ENDIAN_BIG 1
152
#endif
153
#endif
154
155
#if defined(__sparc__)
156
#define CONF_ARCH_SPARC 1
157
#define CONF_ARCH_STRING "sparc"
158
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
159
#define CONF_ARCH_ENDIAN_BIG 1
160
#endif
161
#endif
162
163
#if defined(__ARMEB__)
164
#define CONF_ARCH_ARM 1
165
#define CONF_ARCH_STRING "arm"
166
#define CONF_ARCH_ENDIAN_BIG 1
167
#elif defined(__ARMEL__)
168
#define CONF_ARCH_ARM 1
169
#define CONF_ARCH_STRING "arm"
170
#define CONF_ARCH_ENDIAN_LITTLE 1
171
#elif defined(__aarch64__) || defined(__arm64__) || defined(__ARM_ARCH_ISA_A64)
172
#define CONF_ARCH_ARM64 1
173
#define CONF_ARCH_STRING "arm64"
174
#if defined(__ARM_BIG_ENDIAN)
175
#define CONF_ARCH_ENDIAN_BIG 1
176
#else
177
#define CONF_ARCH_ENDIAN_LITTLE 1
178
#endif
179
#endif
180
181
#if defined(__EMSCRIPTEN__)
182
#define CONF_ARCH_WASM 1
183
#define CONF_ARCH_STRING "wasm32"
184
#endif
185
186
#ifndef CONF_FAMILY_STRING
187
#define CONF_FAMILY_STRING "unknown"
188
#endif
189
190
#ifndef PLATFORM_STRING
191
#define PLATFORM_STRING "unknown"
192
#endif
193
194
#define STRINGIFY2(x) #x
195
#define STRINGIFY(x) STRINGIFY2(x)
196
197
#if defined(PLATFORM_SUFFIX)
198
#define CONF_PLATFORM_STRING PLATFORM_STRING STRINGIFY(PLATFORM_SUFFIX)
199
#else
200
#define CONF_PLATFORM_STRING PLATFORM_STRING
201
#endif
202
203
#ifndef CONF_ARCH_STRING
204
#define CONF_ARCH_STRING "unknown"
205
#endif
206
207
#if defined(CONF_ARCH_ENDIAN_LITTLE)
208
#define CONF_ARCH_ENDIAN_STRING "little endian"
209
#elif defined(CONF_ARCH_ENDIAN_BIG)
210
#define CONF_ARCH_ENDIAN_STRING "big endian"
211
#else
212
#error "Unsupported endianness"
213
#endif
214
215
#endif
src
base
detect.h
Generated by
1.9.8