abi.h 22 KB

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