Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/KWIML/include/kwiml/abi.h
3156 views
1
/*============================================================================
2
Kitware Information Macro Library
3
Copyright 2010-2018 Kitware, Inc.
4
All rights reserved.
5
6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions
8
are met:
9
10
* Redistributions of source code must retain the above copyright
11
notice, this list of conditions and the following disclaimer.
12
13
* Redistributions in binary form must reproduce the above copyright
14
notice, this list of conditions and the following disclaimer in the
15
documentation and/or other materials provided with the distribution.
16
17
* Neither the name of Kitware, Inc. nor the names of its contributors
18
may be used to endorse or promote products derived from this
19
software without specific prior written permission.
20
21
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
============================================================================*/
33
/*
34
This header defines macros with information about the C ABI.
35
Only information that can be determined using the preprocessor at
36
compilation time is available. No try-compile results may be added
37
here. Instead we memorize results on platforms of interest.
38
39
An includer may optionally define the following macros to suppress errors:
40
41
KWIML_ABI_NO_VERIFY = skip verification declarations
42
KWIML_ABI_NO_ERROR_CHAR_SIGN = signedness of 'char' may be unknown
43
KWIML_ABI_NO_ERROR_LONG_LONG = existence of 'long long' may be unknown
44
KWIML_ABI_NO_ERROR_ENDIAN = byte order of CPU may be unknown
45
46
An includer may test the following macros after inclusion:
47
48
KWIML_ABI_VERSION = interface version number # of this header
49
50
KWIML_ABI_SIZEOF_DATA_PTR = sizeof(void*)
51
KWIML_ABI_SIZEOF_CODE_PTR = sizeof(void(*)(void))
52
KWIML_ABI_SIZEOF_FLOAT = sizeof(float)
53
KWIML_ABI_SIZEOF_DOUBLE = sizeof(double)
54
KWIML_ABI_SIZEOF_CHAR = sizeof(char)
55
KWIML_ABI_SIZEOF_SHORT = sizeof(short)
56
KWIML_ABI_SIZEOF_INT = sizeof(int)
57
KWIML_ABI_SIZEOF_LONG = sizeof(long)
58
59
KWIML_ABI_SIZEOF_LONG_LONG = sizeof(long long) or 0 if not a type
60
Undefined if existence is unknown and error suppression macro
61
KWIML_ABI_NO_ERROR_LONG_LONG was defined.
62
63
KWIML_ABI_SIZEOF___INT64 = 8 if '__int64' exists or 0 if not
64
Undefined if existence is unknown.
65
66
KWIML_ABI___INT64_IS_LONG = 1 if '__int64' is 'long' (same type)
67
Undefined otherwise.
68
KWIML_ABI___INT64_IS_LONG_LONG = 1 if '__int64' is 'long long' (same type)
69
Undefined otherwise.
70
KWIML_ABI___INT64_IS_UNIQUE = 1 if '__int64' is a distinct type
71
Undefined otherwise.
72
73
KWIML_ABI_CHAR_IS_UNSIGNED = 1 if 'char' is unsigned, else undefined
74
KWIML_ABI_CHAR_IS_SIGNED = 1 if 'char' is signed, else undefined
75
One of these is defined unless signedness of 'char' is unknown and
76
error suppression macro KWIML_ABI_NO_ERROR_CHAR_SIGN was defined.
77
78
KWIML_ABI_ENDIAN_ID_BIG = id for big-endian (always defined)
79
KWIML_ABI_ENDIAN_ID_LITTLE = id for little-endian (always defined)
80
KWIML_ABI_ENDIAN_ID = id of byte order of target CPU
81
Defined to KWIML_ABI_ENDIAN_ID_BIG or KWIML_ABI_ENDIAN_ID_LITTLE
82
unless byte order is unknown and error suppression macro
83
KWIML_ABI_NO_ERROR_ENDIAN was defined.
84
85
We verify most results using dummy "extern" declarations that are
86
invalid if the macros are wrong. Verification is disabled if
87
suppression macro KWIML_ABI_NO_VERIFY was defined.
88
*/
89
90
#define KWIML_ABI_private_VERSION 1
91
92
/* Guard definition of this version. */
93
#ifndef KWIML_ABI_detail_DEFINED_VERSION_1
94
# define KWIML_ABI_detail_DEFINED_VERSION_1 1
95
# define KWIML_ABI_private_DO_DEFINE
96
#endif
97
98
/* Guard verification of this version. */
99
#if !defined(KWIML_ABI_NO_VERIFY)
100
# ifndef KWIML_ABI_detail_VERIFIED_VERSION_1
101
# define KWIML_ABI_detail_VERIFIED_VERSION_1
102
# define KWIML_ABI_private_DO_VERIFY
103
# endif
104
#endif
105
106
#ifdef KWIML_ABI_private_DO_DEFINE
107
#undef KWIML_ABI_private_DO_DEFINE
108
109
/* Define version as most recent of those included. */
110
#if !defined(KWIML_ABI_VERSION) || KWIML_ABI_VERSION < KWIML_ABI_private_VERSION
111
# undef KWIML_ABI_VERSION
112
# define KWIML_ABI_VERSION 1
113
#endif
114
115
/*--------------------------------------------------------------------------*/
116
#if !defined(KWIML_ABI_SIZEOF_DATA_PTR)
117
# if defined(__SIZEOF_POINTER__)
118
# define KWIML_ABI_SIZEOF_DATA_PTR __SIZEOF_POINTER__
119
# elif defined(_SIZE_PTR)
120
# define KWIML_ABI_SIZEOF_DATA_PTR (_SIZE_PTR >> 3)
121
# elif defined(_LP64) || defined(__LP64__)
122
# define KWIML_ABI_SIZEOF_DATA_PTR 8
123
# elif defined(_ILP32)
124
# define KWIML_ABI_SIZEOF_DATA_PTR 4
125
# elif defined(__64BIT__) /* IBM XL */
126
# define KWIML_ABI_SIZEOF_DATA_PTR 8
127
# elif defined(_M_X64)
128
# define KWIML_ABI_SIZEOF_DATA_PTR 8
129
# elif defined(__ia64)
130
# define KWIML_ABI_SIZEOF_DATA_PTR 8
131
# elif defined(__sparcv9)
132
# define KWIML_ABI_SIZEOF_DATA_PTR 8
133
# elif defined(__x86_64) || defined(__x86_64__)
134
# define KWIML_ABI_SIZEOF_DATA_PTR 8
135
# elif defined(__amd64) || defined(__amd64__)
136
# define KWIML_ABI_SIZEOF_DATA_PTR 8
137
# elif defined(__i386) || defined(__i386__)
138
# define KWIML_ABI_SIZEOF_DATA_PTR 4
139
# elif defined(_M_ARM64)
140
# define KWIML_ABI_SIZEOF_DATA_PTR 8
141
# endif
142
#endif
143
#if !defined(KWIML_ABI_SIZEOF_DATA_PTR)
144
# define KWIML_ABI_SIZEOF_DATA_PTR 4
145
#endif
146
#if !defined(KWIML_ABI_SIZEOF_CODE_PTR)
147
# define KWIML_ABI_SIZEOF_CODE_PTR KWIML_ABI_SIZEOF_DATA_PTR
148
#endif
149
150
/*--------------------------------------------------------------------------*/
151
#if !defined(KWIML_ABI_SIZEOF_CHAR)
152
# define KWIML_ABI_SIZEOF_CHAR 1
153
#endif
154
155
#if !defined(KWIML_ABI_CHAR_IS_UNSIGNED) && !defined(KWIML_ABI_CHAR_IS_SIGNED)
156
# if defined(__CHAR_UNSIGNED__) /* GNU, some IBM XL, others? */
157
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
158
# elif defined(_CHAR_UNSIGNED) /* Intel, IBM XL, MSVC, Borland, others? */
159
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
160
# elif defined(_CHAR_SIGNED) /* IBM XL, others? */
161
# define KWIML_ABI_CHAR_IS_SIGNED 1
162
# elif defined(__CHAR_SIGNED__) /* IBM XL, Watcom, others? */
163
# define KWIML_ABI_CHAR_IS_SIGNED 1
164
# elif defined(__SIGNED_CHARS__) /* EDG, Intel, SGI MIPSpro */
165
# define KWIML_ABI_CHAR_IS_SIGNED 1
166
# elif defined(_CHAR_IS_SIGNED) /* Some SunPro, others? */
167
# define KWIML_ABI_CHAR_IS_SIGNED 1
168
# elif defined(_CHAR_IS_UNSIGNED) /* SunPro, others? */
169
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
170
# elif defined(__GNUC__) /* GNU default */
171
# define KWIML_ABI_CHAR_IS_SIGNED 1
172
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro default */
173
# define KWIML_ABI_CHAR_IS_SIGNED 1
174
# elif defined(__HP_cc) || defined(__HP_aCC) /* HP default (unless +uc) */
175
# define KWIML_ABI_CHAR_IS_SIGNED 1
176
# elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */
177
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
178
# elif defined(__PGIC__) /* PGI default */
179
# define KWIML_ABI_CHAR_IS_SIGNED 1
180
# elif defined(_MSC_VER) /* MSVC default */
181
# define KWIML_ABI_CHAR_IS_SIGNED 1
182
# elif defined(__WATCOMC__) /* Watcom default */
183
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
184
# elif defined(__BORLANDC__) /* Borland default */
185
# define KWIML_ABI_CHAR_IS_SIGNED 1
186
# elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
187
# define KWIML_ABI_CHAR_IS_SIGNED 1 /* (unless +uc) */
188
# endif
189
#endif
190
#if !defined(KWIML_ABI_CHAR_IS_UNSIGNED) && !defined(KWIML_ABI_CHAR_IS_SIGNED) \
191
&& !defined(KWIML_ABI_NO_ERROR_CHAR_SIGN)
192
# error "Signedness of 'char' unknown."
193
#endif
194
195
/*--------------------------------------------------------------------------*/
196
#if !defined(KWIML_ABI_SIZEOF_SHORT)
197
# if defined(__SIZEOF_SHORT__)
198
# define KWIML_ABI_SIZEOF_SHORT __SIZEOF_SHORT__
199
# endif
200
#endif
201
#if !defined(KWIML_ABI_SIZEOF_SHORT)
202
# define KWIML_ABI_SIZEOF_SHORT 2
203
#endif
204
205
/*--------------------------------------------------------------------------*/
206
#if !defined(KWIML_ABI_SIZEOF_INT)
207
# if defined(__SIZEOF_INT__)
208
# define KWIML_ABI_SIZEOF_INT __SIZEOF_INT__
209
# elif defined(_SIZE_INT)
210
# define KWIML_ABI_SIZEOF_INT (_SIZE_INT >> 3)
211
# endif
212
#endif
213
#if !defined(KWIML_ABI_SIZEOF_INT)
214
# define KWIML_ABI_SIZEOF_INT 4
215
#endif
216
217
/*--------------------------------------------------------------------------*/
218
#if !defined(KWIML_ABI_SIZEOF_LONG)
219
# if defined(__SIZEOF_LONG__)
220
# define KWIML_ABI_SIZEOF_LONG __SIZEOF_LONG__
221
# elif defined(_SIZE_LONG)
222
# define KWIML_ABI_SIZEOF_LONG (_SIZE_LONG >> 3)
223
# elif defined(__LONG_MAX__)
224
# if __LONG_MAX__ == 0x7fffffff
225
# define KWIML_ABI_SIZEOF_LONG 4
226
# elif __LONG_MAX__>>32 == 0x7fffffff
227
# define KWIML_ABI_SIZEOF_LONG 8
228
# endif
229
# elif defined(_MSC_VER) /* MSVC and Intel on Windows */
230
# define KWIML_ABI_SIZEOF_LONG 4
231
# endif
232
#endif
233
#if !defined(KWIML_ABI_SIZEOF_LONG)
234
# define KWIML_ABI_SIZEOF_LONG KWIML_ABI_SIZEOF_DATA_PTR
235
#endif
236
237
/*--------------------------------------------------------------------------*/
238
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG)
239
# if defined(__SIZEOF_LONG_LONG__)
240
# define KWIML_ABI_SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__
241
# elif defined(__LONG_LONG_MAX__)
242
# if __LONG_LONG_MAX__ == 0x7fffffff
243
# define KWIML_ABI_SIZEOF_LONG_LONG 4
244
# elif __LONG_LONG_MAX__>>32 == 0x7fffffff
245
# define KWIML_ABI_SIZEOF_LONG_LONG 8
246
# endif
247
# endif
248
#endif
249
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG)
250
# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ \
251
&& !defined(_MSC_VER)
252
# define KWIML_ABI_SIZEOF_LONG_LONG 8
253
# elif defined(_LONG_LONG) /* IBM XL, perhaps others. */
254
# define KWIML_ABI_SIZEOF_LONG_LONG 8
255
# elif defined(__NO_LONG_LONG) /* EDG */
256
# define KWIML_ABI_SIZEOF_LONG_LONG 0
257
# elif defined(__cplusplus) && __cplusplus > 199711L /* C++0x */
258
# define KWIML_ABI_SIZEOF_LONG_LONG 8
259
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
260
# define KWIML_ABI_SIZEOF_LONG_LONG 8
261
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro */
262
# define KWIML_ABI_SIZEOF_LONG_LONG 8
263
# elif defined(__HP_cc) || defined(__HP_aCC) /* HP */
264
# define KWIML_ABI_SIZEOF_LONG_LONG 8
265
# elif defined(__PGIC__) /* PGI */
266
# define KWIML_ABI_SIZEOF_LONG_LONG 8
267
# elif defined(__WATCOMC__) /* Watcom */
268
# define KWIML_ABI_SIZEOF_LONG_LONG 8
269
# elif defined(__INTEL_COMPILER) /* Intel */
270
# define KWIML_ABI_SIZEOF_LONG_LONG 8
271
# elif defined(__BORLANDC__) /* Borland */
272
# if __BORLANDC__ >= 0x0560
273
# define KWIML_ABI_SIZEOF_LONG_LONG 8
274
# else
275
# define KWIML_ABI_SIZEOF_LONG_LONG 0
276
# endif
277
# elif defined(_MSC_VER) /* Microsoft */
278
# if _MSC_VER >= 1310
279
# define KWIML_ABI_SIZEOF_LONG_LONG 8
280
# else
281
# define KWIML_ABI_SIZEOF_LONG_LONG 0
282
# endif
283
# elif defined(__GNUC__) /* GNU */
284
# define KWIML_ABI_SIZEOF_LONG_LONG 8
285
# elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
286
# define KWIML_ABI_SIZEOF_LONG_LONG 8
287
# endif
288
#endif
289
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG) && !defined(KWIML_ABI_NO_ERROR_LONG_LONG)
290
# error "Existence of 'long long' unknown."
291
#endif
292
293
/*--------------------------------------------------------------------------*/
294
#if !defined(KWIML_ABI_SIZEOF___INT64)
295
# if defined(__INTEL_COMPILER)
296
# define KWIML_ABI_SIZEOF___INT64 8
297
# elif defined(_MSC_VER)
298
# define KWIML_ABI_SIZEOF___INT64 8
299
# elif defined(__BORLANDC__)
300
# define KWIML_ABI_SIZEOF___INT64 8
301
# else
302
# define KWIML_ABI_SIZEOF___INT64 0
303
# endif
304
#endif
305
306
#if defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
307
# if KWIML_ABI_SIZEOF_LONG == 8
308
# define KWIML_ABI___INT64_IS_LONG 1
309
# elif defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG == 8
310
# define KWIML_ABI___INT64_IS_LONG_LONG 1
311
# else
312
# define KWIML_ABI___INT64_IS_UNIQUE 1
313
# endif
314
#endif
315
316
/*--------------------------------------------------------------------------*/
317
#if !defined(KWIML_ABI_SIZEOF_FLOAT)
318
# if defined(__SIZEOF_FLOAT__)
319
# define KWIML_ABI_SIZEOF_FLOAT __SIZEOF_FLOAT__
320
# endif
321
#endif
322
#if !defined(KWIML_ABI_SIZEOF_FLOAT)
323
# define KWIML_ABI_SIZEOF_FLOAT 4
324
#endif
325
326
/*--------------------------------------------------------------------------*/
327
#if !defined(KWIML_ABI_SIZEOF_DOUBLE)
328
# if defined(__SIZEOF_DOUBLE__)
329
# define KWIML_ABI_SIZEOF_DOUBLE __SIZEOF_DOUBLE__
330
# endif
331
#endif
332
#if !defined(KWIML_ABI_SIZEOF_DOUBLE)
333
# define KWIML_ABI_SIZEOF_DOUBLE 8
334
#endif
335
336
/*--------------------------------------------------------------------------*/
337
/* Identify possible endian cases. The macro KWIML_ABI_ENDIAN_ID will be
338
defined to one of these, or undefined if unknown. */
339
#if !defined(KWIML_ABI_ENDIAN_ID_BIG)
340
# define KWIML_ABI_ENDIAN_ID_BIG 4321
341
#endif
342
#if !defined(KWIML_ABI_ENDIAN_ID_LITTLE)
343
# define KWIML_ABI_ENDIAN_ID_LITTLE 1234
344
#endif
345
#if KWIML_ABI_ENDIAN_ID_BIG == KWIML_ABI_ENDIAN_ID_LITTLE
346
# error "KWIML_ABI_ENDIAN_ID_BIG == KWIML_ABI_ENDIAN_ID_LITTLE"
347
#endif
348
349
#if defined(KWIML_ABI_ENDIAN_ID) /* Skip #elif cases if already defined. */
350
351
/* Use dedicated symbols if the compiler defines them. Do this first
352
because some architectures allow runtime byte order selection by
353
the operating system (values for such architectures below are
354
guesses for compilers that do not define a dedicated symbol).
355
Ensure that only one is defined in case the platform or a header
356
defines both as possible values for some third symbol. */
357
#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
358
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
359
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
360
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
361
#elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
362
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
363
#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
364
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
365
366
/* Alpha */
367
#elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
368
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
369
370
/* Arm */
371
#elif defined(__arm__)
372
# if !defined(__ARMEB__)
373
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
374
# else
375
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
376
# endif
377
378
/* Intel x86 */
379
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
380
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
381
#elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
382
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
383
#elif defined(__MWERKS__) && defined(__INTEL__)
384
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
385
386
/* Intel x86-64 */
387
#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
388
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
389
#elif defined(__amd64) || defined(__amd64__)
390
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
391
392
/* Intel Architecture-64 (Itanium) */
393
#elif defined(__ia64) || defined(__ia64__)
394
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
395
#elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
396
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
397
398
/* PowerPC */
399
#elif defined(__powerpc) || defined(__powerpc__)
400
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
401
#elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__)
402
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
403
404
/* SPARC */
405
#elif defined(__sparc) || defined(__sparc__)
406
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
407
408
/* HP/PA RISC */
409
#elif defined(__hppa) || defined(__hppa__)
410
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
411
412
/* LoongArch64 */
413
#elif defined(__loongarch64)
414
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
415
416
/* Motorola 68k */
417
#elif defined(__m68k__) || defined(M68000)
418
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
419
420
/* MIPSel (MIPS little endian) */
421
#elif defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
422
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
423
424
/* MIPSeb (MIPS big endian) */
425
#elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
426
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
427
428
/* MIPS (fallback, big endian) */
429
#elif defined(__mips) || defined(__mips__) || defined(__MIPS__)
430
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
431
432
/* NIOS2 */
433
#elif defined(__NIOS2__) || defined(__NIOS2) || defined(__nios2__)
434
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
435
436
/* OpenRISC 1000 */
437
#elif defined(__or1k__)
438
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
439
440
/* RS/6000 */
441
#elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER)
442
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
443
#elif defined(_ARCH_PWR) || defined(_ARCH_PWR2)
444
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
445
446
/* System/370 */
447
#elif defined(__370__) || defined(__THW_370__)
448
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
449
450
/* System/390 */
451
#elif defined(__s390__) || defined(__s390x__)
452
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
453
454
/* z/Architecture */
455
#elif defined(__SYSC_ZARCH__)
456
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
457
458
/* VAX */
459
#elif defined(__vax__)
460
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
461
462
/* Aarch64 */
463
#elif defined(__aarch64__)
464
# if !defined(__AARCH64EB__)
465
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
466
# else
467
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
468
# endif
469
470
/* Aarch64 (Windows) */
471
#elif defined(_M_ARM64)
472
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
473
474
/* Xtensa */
475
#elif defined(__XTENSA_EB__)
476
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
477
#elif defined(__XTENSA_EL__)
478
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
479
480
/* RISC-V */
481
#elif defined(__riscv) || defined(__riscv__)
482
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
483
484
/* Sunway */
485
#elif defined(__sw_64) || defined(__sw_64__)
486
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
487
488
/* Unknown CPU */
489
#elif !defined(KWIML_ABI_NO_ERROR_ENDIAN)
490
# error "Byte order of target CPU unknown."
491
#endif
492
493
#endif /* KWIML_ABI_private_DO_DEFINE */
494
495
/*--------------------------------------------------------------------------*/
496
#ifdef KWIML_ABI_private_DO_VERIFY
497
#undef KWIML_ABI_private_DO_VERIFY
498
499
#if defined(_MSC_VER)
500
# pragma warning (push)
501
# pragma warning (disable:4309) /* static_cast truncation of constant value */
502
# pragma warning (disable:4310) /* cast truncates constant value */
503
#endif
504
505
#if defined(__cplusplus) && !defined(__BORLANDC__)
506
#define KWIML_ABI_private_STATIC_CAST(t,v) static_cast<t>(v)
507
#else
508
#define KWIML_ABI_private_STATIC_CAST(t,v) (t)(v)
509
#endif
510
511
#define KWIML_ABI_private_VERIFY(n, x, y) KWIML_ABI_private_VERIFY_0(KWIML_ABI_private_VERSION, n, x, y)
512
#define KWIML_ABI_private_VERIFY_0(V, n, x, y) KWIML_ABI_private_VERIFY_1(V, n, x, y)
513
#define KWIML_ABI_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]
514
515
#define KWIML_ABI_private_VERIFY_SAME_IMPL(n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
516
#define KWIML_ABI_private_VERIFY_SAME_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y)
517
#define KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y) extern int (*n##_v##V)(x*); extern int (*n##_v##V)(y*)
518
519
#define KWIML_ABI_private_VERIFY_DIFF_IMPL(n, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
520
#define KWIML_ABI_private_VERIFY_DIFF_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y)
521
#if defined(__cplusplus)
522
# define KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y) extern int* n##_v##V(x*); extern char* n##_v##V(y*)
523
#else
524
# define KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y) extern int* n##_v##V(x*) /* TODO: possible? */
525
#endif
526
527
#define KWIML_ABI_private_VERIFY_BOOL(m, b) KWIML_ABI_private_VERIFY(KWIML_ABI_detail_VERIFY_##m, 2, (b)?2:3)
528
#define KWIML_ABI_private_VERIFY_SIZE(m, t) KWIML_ABI_private_VERIFY(KWIML_ABI_detail_VERIFY_##m, m, sizeof(t))
529
#define KWIML_ABI_private_VERIFY_SAME(m, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
530
#define KWIML_ABI_private_VERIFY_DIFF(m, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
531
532
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_DATA_PTR, int*);
533
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_CODE_PTR, int(*)(int));
534
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_CHAR, char);
535
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_SHORT, short);
536
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_INT, int);
537
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_LONG, long);
538
#if defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG > 0
539
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_LONG_LONG, long long);
540
#endif
541
#if defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
542
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF___INT64, __int64);
543
#endif
544
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_FLOAT, float);
545
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_DOUBLE, double);
546
547
#if defined(KWIML_ABI___INT64_IS_LONG)
548
KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG, __int64, long);
549
#elif defined(KWIML_ABI___INT64_IS_LONG_LONG)
550
KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG_LONG, __int64, long long);
551
#elif defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
552
KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG, __int64, long);
553
# if defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG > 0
554
KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG_LONG, __int64, long long);
555
# endif
556
#endif
557
558
#if defined(KWIML_ABI_CHAR_IS_UNSIGNED)
559
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED,
560
KWIML_ABI_private_STATIC_CAST(char, 0x80) > 0);
561
#elif defined(KWIML_ABI_CHAR_IS_SIGNED)
562
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED,
563
KWIML_ABI_private_STATIC_CAST(char, 0x80) < 0);
564
#endif
565
566
#undef KWIML_ABI_private_VERIFY_DIFF
567
#undef KWIML_ABI_private_VERIFY_SAME
568
#undef KWIML_ABI_private_VERIFY_SIZE
569
#undef KWIML_ABI_private_VERIFY_BOOL
570
571
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL_1
572
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL_0
573
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL
574
575
#undef KWIML_ABI_private_VERIFY_SAME_IMPL_1
576
#undef KWIML_ABI_private_VERIFY_SAME_IMPL_0
577
#undef KWIML_ABI_private_VERIFY_SAME_IMPL
578
579
#undef KWIML_ABI_private_VERIFY_1
580
#undef KWIML_ABI_private_VERIFY_0
581
#undef KWIML_ABI_private_VERIFY
582
583
#undef KWIML_ABI_private_STATIC_CAST
584
585
#if defined(_MSC_VER)
586
# pragma warning (pop)
587
#endif
588
589
#endif /* KWIML_ABI_private_DO_VERIFY */
590
591
#undef KWIML_ABI_private_VERSION
592
593