Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_macros.h @ 616:5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
- cosmetic cleanups for consistency
- added runtime detection to dyncall_macros.h to handle some edge cases
- fixed detection of native thiscall callconv for builds not using MSVC but using (or adhering to) the MSVC runtime (e.g. ReactOS' MinGW based RosBE)
author | Tassilo Philipp |
---|---|
date | Sun, 02 Oct 2022 13:58:33 +0200 |
parents | dfc2e6ee8782 |
children | 6a8aac9b2bcf |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_macros.h | |
6 Description: Platform detection macros | |
7 License: | |
8 | |
281 | 9 Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 | |
28 /* | |
29 | |
30 dyncall macros | |
31 | |
32 Platform detection, specific defines and configuration. | |
33 The purpose of this file is to provide coherent platform and compiler | |
34 specific defines. So instead of defines like WIN32, _OpenBSD_ or | |
35 __GNUC__, one should use DC__OS_Win32, DC__OS_OpenBSD or DC__C_GNU, | |
36 respectively. | |
37 | |
38 REVISION | |
39 2007/12/11 initial | |
40 | |
41 */ | |
42 | |
43 | |
44 #ifndef DYNCALL_MACROS_H | |
45 #define DYNCALL_MACROS_H | |
46 | |
47 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
48 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
49 /* -- Platform specific #defines ------------------------------------ */ |
0 | 50 |
51 /* MS Windows XP x64/Vista64 or later. */ | |
52 #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
53 # define DC__OS_Win64 |
0 | 54 |
55 /* MS Windows NT/95/98/ME/2000/XP/Vista32. */ | |
56 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__WINDOWS__) || defined(_WINDOWS) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
57 # define DC__OS_Win32 |
0 | 58 |
59 /* All the OS' based on Darwin OS (MacOS X, OpenDarwin). Note that '__APPLE__' may be defined for classic MacOS, too. */ | |
60 /* __MACOSX__ is not defined in gcc assembler mode (switch: -S) */ | |
61 #elif defined(__APPLE__) || defined(__Darwin__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
62 # define DC__OS_Darwin |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
63 # if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
64 # define DC__OS_IPhone |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
65 # else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */ |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
66 # define DC__OS_MacOSX |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
67 # endif |
0 | 68 |
69 /* The most popular open source Unix-like OS - Linux. */ | |
70 #elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
71 # define DC__OS_Linux |
0 | 72 |
73 /* The most powerful open source Unix-like OS - FreeBSD. */ | |
254
9d70178c1ded
- better cpp checking whether dlinfo() is available, to also cover GLIBC based systems that don't identify as Linux (e.g. debian/k*BSD)
Tassilo Philipp
parents:
204
diff
changeset
|
74 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* latter is (also) used by systems using FreeBSD kernel, e.g. Debian/kFreeBSD, which could be detected specifically by also checking for __GLIBC__ */ |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
75 # define DC__OS_FreeBSD |
0 | 76 |
77 /* The most secure open source Unix-like OS - OpenBSD. */ | |
78 #elif defined(__OpenBSD__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
79 # define DC__OS_OpenBSD |
0 | 80 |
81 /* The most portable open source Unix-like OS - NetBSD. */ | |
82 #elif defined(__NetBSD__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
83 # define DC__OS_NetBSD |
0 | 84 |
85 /* The FreeBSD fork having heavy clusterization in mind - DragonFlyBSD. */ | |
86 #elif defined(__DragonFly__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
87 # define DC__OS_DragonFlyBSD |
0 | 88 |
89 /* Sun's Unix-like OS - SunOS / Solaris. */ | |
90 #elif defined(__sun__) || defined(__sun) || defined(sun) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
91 # define DC__OS_SunOS |
0 | 92 |
93 /* The Nintendo DS (homebrew) using devkitpro. */ | |
94 #elif defined(__nds__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
95 # define DC__OS_NDS |
0 | 96 |
97 /* The PlayStation Portable (homebrew) SDK. */ | |
98 #elif defined(__psp__) || defined(PSP) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
99 # define DC__OS_PSP |
0 | 100 |
101 /* Haiku (BeOS alike). */ | |
102 #elif defined(__HAIKU__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
103 # define DC__OS_BeOS |
0 | 104 |
105 /* The Unix successor - Plan9 from Bell Labs */ | |
106 #elif defined(Plan9) || defined(__Plan9__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
107 # define DC__OS_Plan9 |
0 | 108 |
109 /* Digital's Unix-like OS - VMS */ | |
110 #elif defined(__vms) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
111 # define DC__OS_VMS |
0 | 112 |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
113 /* Tanenbaum's Microkernel OS - Minix */ |
0 | 114 #elif defined(__minix) |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
115 # define DC__OS_Minix |
174
a8052efbde18
- loosened OS detection macros a bit to not bail out and thus make it easier to use dyncall on baremetal
cslag
parents:
141
diff
changeset
|
116 |
a8052efbde18
- loosened OS detection macros a bit to not bail out and thus make it easier to use dyncall on baremetal
cslag
parents:
141
diff
changeset
|
117 /* Unable to determine OS, which is probably ok (e.g. baremetal stuff, etc.). */ |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
118 #else |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
119 # define DC__OS_UNKNOWN |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
120 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
121 #endif |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
122 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
123 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
124 /* windows sub envs */ |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
125 #if defined(DC__OS_Win32) || defined(DC__OS_Win64) |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
126 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
127 /* The "Linux-like environment for Windows" - Cygwin. */ |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
128 # if defined(__CYGWIN__) |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
129 # define DC__OS_Cygwin |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
130 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
131 /* The "Minimalist GNU for Windows" - MinGW. */ |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
132 # elif defined(__MINGW32__) || defined(__MINGW64__) |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
133 # define DC__OS_MinGW |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
134 # endif |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
135 |
0 | 136 #endif |
137 | |
138 | |
139 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
140 /* -- Compiler specific #defines ------------------------------------ */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
141 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
142 /* Don't change the order, b/c some compilers use same #defines compatibility */ |
0 | 143 |
144 /* Intel's C/C++ compiler. */ | |
145 #if defined(__INTEL_COMPILER) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
146 # define DC__C_Intel |
0 | 147 |
148 /* MS C/C++ compiler. */ | |
149 #elif defined(_MSC_VER) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
150 # define DC__C_MSVC |
0 | 151 |
152 /* LLVM clang. */ | |
268
03f0b683918a
- reintroduced .note.GNU-stack section, as mentioned in prev commit
Tassilo Philipp
parents:
261
diff
changeset
|
153 #elif defined(__clang__) || defined(__llvm__) |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
154 # define DC__C_CLANG |
0 | 155 |
156 /* The GNU Compiler Collection - GCC. */ | |
157 #elif defined(__GNUC__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
158 # define DC__C_GNU |
0 | 159 |
160 /* Watcom compiler. */ | |
161 #elif defined(__WATCOMC__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
162 # define DC__C_WATCOM |
0 | 163 |
164 /* Portable C Compiler. */ | |
165 #elif defined(__PCC__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
166 # define DC__C_PCC |
0 | 167 |
168 /* Sun Pro C. */ | |
169 #elif defined(__SUNPRO_C) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
170 # define DC__C_SUNPRO |
0 | 171 |
172 /* Undetected C Compiler. */ | |
173 #else | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
174 # define DC__C_UNKNOWN |
0 | 175 #endif |
176 | |
177 | |
178 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
179 /* -- Architecture -------------------------------------------------- */ |
0 | 180 |
181 /* Check architecture. */ | |
31
6e7b1b7ad9d3
Fixed failing builds when the compiler is ICC/ICPC
Snaipe <franklinmathieu@gmail.com>
parents:
0
diff
changeset
|
182 #if defined(_M_X64_) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) |
6e7b1b7ad9d3
Fixed failing builds when the compiler is ICC/ICPC
Snaipe <franklinmathieu@gmail.com>
parents:
0
diff
changeset
|
183 # define DC__Arch_AMD64 |
6e7b1b7ad9d3
Fixed failing builds when the compiler is ICC/ICPC
Snaipe <franklinmathieu@gmail.com>
parents:
0
diff
changeset
|
184 #elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__386__) || defined(__i386) |
0 | 185 # define DC__Arch_Intel_x86 |
186 #elif defined(_M_IA64) || defined(__ia64__) | |
187 # define DC__Arch_Itanium | |
188 #elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__power__) | |
189 # if defined(__ppc64__) || defined(_ARCH_PPC64) || defined(__power64__) || defined(__powerpc64__) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
190 # define DC__Arch_PPC64 |
0 | 191 # else |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
192 # define DC__Arch_PPC32 |
0 | 193 # endif |
194 #elif defined(__mips64__) || defined(__mips64) | |
195 # define DC__Arch_MIPS64 | |
196 #elif defined(_M_MRX000) || defined(__mips__) || defined(__mips) || defined(_mips) | |
197 # define DC__Arch_MIPS | |
198 #elif defined(__arm__) | |
199 # define DC__Arch_ARM | |
371
451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
Tassilo Philipp
parents:
302
diff
changeset
|
200 #elif defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64) || defined(__arm64__) |
0 | 201 # define DC__Arch_ARM64 |
202 #elif defined(__sh__) | |
203 # define DC__Arch_SuperH | |
180 | 204 #elif defined(__sparc) || defined(__sparc__) |
205 # if defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || defined(__arch64__) | |
206 # define DC__Arch_Sparc64 | |
207 # else | |
208 # define DC__Arch_Sparc | |
209 # endif | |
0 | 210 #endif |
211 | |
212 | |
213 | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
214 /* -- Runtime ------------------------------------------------------- */ |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
215 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
216 #if defined(__MSVCRT__) |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
217 # define DC__RT_MSVCRT |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
218 #endif |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
219 |
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
220 |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
221 /* -- Rough OS classification --------------------------------------- */ |
0 | 222 |
223 #if defined(DC__OS_Win32) || defined(DC__OS_Win64) | |
224 # define DC_WINDOWS | |
225 #elif defined(DC__OS_Plan9) | |
226 # define DC_PLAN9 | |
227 #elif defined(DC__OS_NDS) || defined(DC__OS_PSP) | |
228 # define DC_OTHER | |
229 #else | |
230 # define DC_UNIX | |
231 #endif | |
232 | |
233 | |
234 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
235 /* -- Misc machine-dependent modes, ABIs, etc. ---------------------- */ |
0 | 236 |
237 #if defined(__arm__) && !defined(__thumb__) | |
238 # define DC__Arch_ARM_ARM | |
239 #elif defined(__arm__) && defined(__thumb__) | |
240 # define DC__Arch_ARM_THUMB | |
241 #endif | |
242 | |
243 #if defined(DC__Arch_ARM_ARM) || defined(DC__Arch_ARM_THUMB) | |
244 # if defined(__ARM_EABI__) || defined(DC__OS_NDS) | |
245 # if defined (__ARM_PCS_VFP) && (__ARM_PCS_VFP == 1) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
246 # define DC__ABI_ARM_HF |
0 | 247 # else |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
248 # define DC__ABI_ARM_EABI |
0 | 249 # endif |
250 # elif defined(__APCS_32__) | |
251 # define DC__ABI_ARM_OABI | |
252 # endif | |
253 #endif /* ARM */ | |
254 | |
255 #if defined(DC__Arch_MIPS) || defined(DC__Arch_MIPS64) | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
256 # if defined(_ABIO32) || defined(__mips_o32) || defined(_MIPS_ARCH_MIPS1) || defined(_MIPS_ARCH_MIPS2) |
0 | 257 # define DC__ABI_MIPS_O32 |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
258 # elif defined(_ABI64) || defined(__mips_n64) |
112 | 259 # define DC__ABI_MIPS_N64 |
0 | 260 # elif defined(_ABIN32) |
261 # define DC__ABI_MIPS_N32 | |
262 # else | |
263 # define DC__ABI_MIPS_EABI | |
264 # endif | |
302
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
265 /* Set extra flag to know if FP hardware ABI, default to yes, if unsure */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
266 # if (defined(__mips_hard_float) && (__mips_hard_float == 1)) || !defined(__mips_soft_float) || (__mips_soft_float != 1) |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
267 # define DC__ABI_HARDFLOAT /* @@@ make this general for all archs? */ |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
268 # else |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
269 # define DC__ABI_SOFTFLOAT |
d55f9d508074
- mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents:
281
diff
changeset
|
270 # endif |
0 | 271 #endif /* MIPS */ |
272 | |
273 #if defined(DC__Arch_PPC64) | |
274 # if defined(_CALL_ELF) | |
275 # define DC__ABI_PPC64_ELF_V _CALL_ELF | |
276 # else | |
277 # define DC__ABI_PPC64_ELF_V 0 /* 0 means not explicitly set, otherwise this is 1 (big endian) and 2 (little endian) */ | |
278 # endif | |
112 | 279 #endif /* PPC64 */ |
0 | 280 |
281 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
282 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
283 /* -- Endianness detection ------------------------------------------ */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
284 |
0 | 285 #if defined(DC__Arch_Intel_x86) || defined(DC__Arch_AMD64) /* always little */ |
286 # define DC__Endian_LITTLE | |
179 | 287 #elif defined(DC__Arch_Sparc) /* always purely big until v9 */ |
0 | 288 # define DC__Endian_BIG |
289 #else /* all others are bi-endian */ | |
290 /* @@@check flags used on following bi-endianness archs: | |
291 DC__Arch_Itanium | |
292 DC__Arch_PPC32 | |
293 DC__Arch_PPC64 | |
294 DC__Arch_SuperH | |
295 */ | |
588
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
296 # if (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 1)) || defined(MIPSEB) || defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(__ARMEB__) || defined(__AARCH64EB__) |
0 | 297 # define DC__Endian_BIG |
588
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
298 # elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(MIPSEL) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(__ARMEL__) || defined(__AARCH64EL__) |
0 | 299 # define DC__Endian_LITTLE |
204
a74e2cd93348
- sparc64 endian detection on non-explicit platforms
Tassilo Philipp
parents:
188
diff
changeset
|
300 # elif defined(DC__Arch_Sparc64) && !defined(__BYTE_ORDER__) /* Sparc64 default is big-endian, except if explicitly defined */ |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
301 # define DC__Endian_BIG |
588
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
302 # elif defined(BYTE_ORDER) || defined(_BYTE_ORDER) || defined(__BYTE_ORDER__) /* explicitly set byte order, either through compiler or platform specific endian.h */ |
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
303 # if (defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || (defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN)) || (defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
304 # define DC__Endian_BIG |
588
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
305 # elif (defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN)) || (defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN)) || (defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
306 # define DC__Endian_LITTLE |
188 | 307 # endif |
588
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
308 # elif (defined(_BIG_ENDIAN) && (_BIG_ENDIAN == 1)) || (defined(__BIG_ENDIAN__) && (__BIG_ENDIAN__ == 1)) /* explicitly set as on/off */ |
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
309 # define DC__Endian_BIG |
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
310 # elif (defined(_LITTLE_ENDIAN) && (_LITTLE_ENDIAN == 1)) || (defined(__LITTLE_ENDIAN__) && (__LITTLE_ENDIAN__ == 1)) /* explicitly set as on/off */ |
dfc2e6ee8782
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
Tassilo Philipp
parents:
531
diff
changeset
|
311 # define DC__Endian_LITTLE |
0 | 312 # endif /* no else, leave unset if not sure */ |
313 #endif | |
314 | |
315 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
316 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
317 /* -- Internal macro/tag -------------------------------------------- */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
318 |
0 | 319 #if !defined(DC_API) |
188 | 320 # define DC_API |
0 | 321 #endif |
322 | |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
323 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
324 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
325 /* -- Library feature support macors -------------------------------- */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
326 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
327 /* macros for specifying lesser used feature support (main features like basic |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
328 call and callback support are required for a platform implementation */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
329 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
330 /* syscalls */ |
531 | 331 #if (defined(DC__Arch_Intel_x86) || (defined(DC__Arch_AMD64) && defined(DC_UNIX)) || defined(DC__Arch_PPC32) || defined(DC__Arch_PPC64)) && \ |
332 !defined(DC__OS_MacOSX) && !defined(DC__OS_Plan9) && !defined(DC__OS_NDS) && !defined(DC__OS_PSP) && !defined(DC__OS_Minix) && !defined(DC__OS_SunOS) && !defined(DC__OS_BeOS) | |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
333 # define DC__Feature_Syscall |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
334 #endif |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
335 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
336 /* aggregate (struct, union) by value */ |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
337 #if defined(DC__Arch_AMD64) |
616
5d999f5c13d1
- fixed mingw and cygwin env detection (was always shadowed by _WIN32 macro detection, and __MINGW__ macro check was wrong to begin with)
Tassilo Philipp
parents:
588
diff
changeset
|
338 # define DC__Feature_AggrByVal |
488
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
339 #endif |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
340 |
1455b6beedd9
- added feature-testing macros for syscall and aggregate (struct, union) by value support
Tassilo Philipp
parents:
371
diff
changeset
|
341 |
0 | 342 #endif /* DYNCALL_MACROS_H */ |
343 |