ABI.h.in 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. /*============================================================================
  2. Kitware Information Macro Library
  3. Copyright 2010-2011 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. #ifndef @KWIML@_ABI_H
  29. #define @KWIML@_ABI_H
  30. /*
  31. This header defines macros with information about the C ABI.
  32. Only information that can be determined using the preprocessor at
  33. compilation time is available. No try-compile results may be added
  34. here. Instead we memorize results on platforms of interest.
  35. An includer may optionally define the following macros to suppress errors:
  36. @KWIML@_ABI_NO_VERIFY = skip verification declarations
  37. @KWIML@_ABI_NO_ERROR_CHAR_SIGN = signedness of 'char' may be unknown
  38. @KWIML@_ABI_NO_ERROR_LONG_LONG = existence of 'long long' may be unknown
  39. @KWIML@_ABI_NO_ERROR_ENDIAN = byte order of CPU may be unknown
  40. An includer may test the following macros after inclusion:
  41. @KWIML@_ABI_SIZEOF_DATA_PTR = sizeof(void*)
  42. @KWIML@_ABI_SIZEOF_CODE_PTR = sizeof(void(*)(void))
  43. @KWIML@_ABI_SIZEOF_FLOAT = sizeof(float)
  44. @KWIML@_ABI_SIZEOF_DOUBLE = sizeof(double)
  45. @KWIML@_ABI_SIZEOF_CHAR = sizeof(char)
  46. @KWIML@_ABI_SIZEOF_SHORT = sizeof(short)
  47. @KWIML@_ABI_SIZEOF_INT = sizeof(int)
  48. @KWIML@_ABI_SIZEOF_LONG = sizeof(long)
  49. @KWIML@_ABI_SIZEOF_LONG_LONG = sizeof(long long) or 0 if not a type
  50. Undefined if existence is unknown and error suppression macro
  51. @KWIML@_ABI_NO_ERROR_LONG_LONG was defined.
  52. @KWIML@_ABI_SIZEOF___INT64 = 8 if '__int64' exists or 0 if not
  53. Undefined if existence is unknown.
  54. @KWIML@_ABI___INT64_IS_LONG = 1 if '__int64' is 'long' (same type)
  55. Undefined otherwise.
  56. @KWIML@_ABI___INT64_IS_LONG_LONG = 1 if '__int64' is 'long long' (same type)
  57. Undefined otherwise.
  58. @KWIML@_ABI___INT64_IS_UNIQUE = 1 if '__int64' is a distinct type
  59. Undefined otherwise.
  60. @KWIML@_ABI_CHAR_IS_UNSIGNED = 1 if 'char' is unsigned, else undefined
  61. @KWIML@_ABI_CHAR_IS_SIGNED = 1 if 'char' is signed, else undefined
  62. One of these is defined unless signedness of 'char' is unknown and
  63. error suppression macro @KWIML@_ABI_NO_ERROR_CHAR_SIGN was defined.
  64. @KWIML@_ABI_ENDIAN_ID_BIG = id for big-endian (always defined)
  65. @KWIML@_ABI_ENDIAN_ID_LITTLE = id for little-endian (always defined)
  66. @KWIML@_ABI_ENDIAN_ID = id of byte order of target CPU
  67. Defined to @KWIML@_ABI_ENDIAN_ID_BIG or @KWIML@_ABI_ENDIAN_ID_LITTLE
  68. unless byte order is unknown and error suppression macro
  69. @KWIML@_ABI_NO_ERROR_ENDIAN was defined.
  70. We verify most results using dummy "extern" declarations that are
  71. invalid if the macros are wrong. Verification is disabled if
  72. suppression macro @KWIML@_ABI_NO_VERIFY was defined.
  73. */
  74. /*--------------------------------------------------------------------------*/
  75. #if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR)
  76. # if defined(__SIZEOF_POINTER__)
  77. # define @KWIML@_ABI_SIZEOF_DATA_PTR __SIZEOF_POINTER__
  78. # elif defined(_SIZE_PTR)
  79. # define @KWIML@_ABI_SIZEOF_DATA_PTR (_SIZE_PTR >> 3)
  80. # elif defined(_LP64) || defined(__LP64__)
  81. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  82. # elif defined(_ILP32)
  83. # define @KWIML@_ABI_SIZEOF_DATA_PTR 4
  84. # elif defined(__64BIT__) /* IBM XL */
  85. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  86. # elif defined(_M_X64)
  87. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  88. # elif defined(__ia64)
  89. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  90. # elif defined(__sparcv9)
  91. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  92. # elif defined(__x86_64) || defined(__x86_64__)
  93. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  94. # elif defined(__amd64) || defined(__amd64__)
  95. # define @KWIML@_ABI_SIZEOF_DATA_PTR 8
  96. # elif defined(__i386) || defined(__i386__)
  97. # define @KWIML@_ABI_SIZEOF_DATA_PTR 4
  98. # endif
  99. #endif
  100. #if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR)
  101. # define @KWIML@_ABI_SIZEOF_DATA_PTR 4
  102. #endif
  103. #if !defined(@KWIML@_ABI_SIZEOF_CODE_PTR)
  104. # define @KWIML@_ABI_SIZEOF_CODE_PTR @KWIML@_ABI_SIZEOF_DATA_PTR
  105. #endif
  106. /*--------------------------------------------------------------------------*/
  107. #if !defined(@KWIML@_ABI_SIZEOF_CHAR)
  108. # define @KWIML@_ABI_SIZEOF_CHAR 1
  109. #endif
  110. #if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED)
  111. # if defined(__CHAR_UNSIGNED__) /* GNU, some IBM XL, others? */
  112. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1
  113. # elif defined(_CHAR_UNSIGNED) /* Intel, IBM XL, MSVC, Borland, others? */
  114. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1
  115. # elif defined(_CHAR_SIGNED) /* IBM XL, others? */
  116. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  117. # elif defined(__CHAR_SIGNED__) /* IBM XL, Watcom, others? */
  118. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  119. # elif defined(__SIGNED_CHARS__) /* EDG, Intel, SGI MIPSpro */
  120. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  121. # elif defined(_CHAR_IS_SIGNED) /* Some SunPro, others? */
  122. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  123. # elif defined(_CHAR_IS_UNSIGNED) /* SunPro, others? */
  124. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1
  125. # elif defined(__GNUC__) /* GNU default */
  126. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  127. # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro default */
  128. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  129. # elif defined(__HP_cc) || defined(__HP_aCC) /* HP default (unless +uc) */
  130. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  131. # elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */
  132. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1
  133. # elif defined(__PGIC__) /* PGI default */
  134. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  135. # elif defined(_MSC_VER) /* MSVC default */
  136. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  137. # elif defined(__WATCOMC__) /* Watcom default */
  138. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1
  139. # elif defined(__BORLANDC__) /* Borland default */
  140. # define @KWIML@_ABI_CHAR_IS_SIGNED 1
  141. # elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
  142. # define @KWIML@_ABI_CHAR_IS_SIGNED 1 /* (unless +uc) */
  143. # endif
  144. #endif
  145. #if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) \
  146. && !defined(@KWIML@_ABI_NO_ERROR_CHAR_SIGN)
  147. # error "Signedness of 'char' unknown."
  148. #endif
  149. /*--------------------------------------------------------------------------*/
  150. #if !defined(@KWIML@_ABI_SIZEOF_SHORT)
  151. # if defined(__SIZEOF_SHORT__)
  152. # define @KWIML@_ABI_SIZEOF_SHORT __SIZEOF_SHORT__
  153. # endif
  154. #endif
  155. #if !defined(@KWIML@_ABI_SIZEOF_SHORT)
  156. # define @KWIML@_ABI_SIZEOF_SHORT 2
  157. #endif
  158. /*--------------------------------------------------------------------------*/
  159. #if !defined(@KWIML@_ABI_SIZEOF_INT)
  160. # if defined(__SIZEOF_INT__)
  161. # define @KWIML@_ABI_SIZEOF_INT __SIZEOF_INT__
  162. # elif defined(_SIZE_INT)
  163. # define @KWIML@_ABI_SIZEOF_INT (_SIZE_INT >> 3)
  164. # endif
  165. #endif
  166. #if !defined(@KWIML@_ABI_SIZEOF_INT)
  167. # define @KWIML@_ABI_SIZEOF_INT 4
  168. #endif
  169. /*--------------------------------------------------------------------------*/
  170. #if !defined(@KWIML@_ABI_SIZEOF_LONG)
  171. # if defined(__SIZEOF_LONG__)
  172. # define @KWIML@_ABI_SIZEOF_LONG __SIZEOF_LONG__
  173. # elif defined(_SIZE_LONG)
  174. # define @KWIML@_ABI_SIZEOF_LONG (_SIZE_LONG >> 3)
  175. # elif defined(__LONG_MAX__)
  176. # if __LONG_MAX__ == 0x7fffffff
  177. # define @KWIML@_ABI_SIZEOF_LONG 4
  178. # elif __LONG_MAX__>>32 == 0x7fffffff
  179. # define @KWIML@_ABI_SIZEOF_LONG 8
  180. # endif
  181. # elif defined(_MSC_VER) /* MSVC and Intel on Windows */
  182. # define @KWIML@_ABI_SIZEOF_LONG 4
  183. # endif
  184. #endif
  185. #if !defined(@KWIML@_ABI_SIZEOF_LONG)
  186. # define @KWIML@_ABI_SIZEOF_LONG @KWIML@_ABI_SIZEOF_DATA_PTR
  187. #endif
  188. /*--------------------------------------------------------------------------*/
  189. #if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG)
  190. # if defined(__SIZEOF_LONG_LONG__)
  191. # define @KWIML@_ABI_SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__
  192. # elif defined(__LONG_LONG_MAX__)
  193. # if __LONG_LONG_MAX__ == 0x7fffffff
  194. # define @KWIML@_ABI_SIZEOF_LONG_LONG 4
  195. # elif __LONG_LONG_MAX__>>32 == 0x7fffffff
  196. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  197. # endif
  198. # endif
  199. #endif
  200. #if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG)
  201. # if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ \
  202. && !defined(_MSC_VER)
  203. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  204. # elif defined(_LONG_LONG) /* IBM XL, perhaps others. */
  205. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  206. # elif defined(__NO_LONG_LONG) /* EDG */
  207. # define @KWIML@_ABI_SIZEOF_LONG_LONG 0
  208. # elif defined(__cplusplus) && __cplusplus > 199711L /* C++0x */
  209. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  210. # elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
  211. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  212. # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro */
  213. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  214. # elif defined(__HP_cc) || defined(__HP_aCC) /* HP */
  215. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  216. # elif defined(__PGIC__) /* PGI */
  217. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  218. # elif defined(__WATCOMC__) /* Watcom */
  219. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  220. # elif defined(__INTEL_COMPILER) /* Intel */
  221. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  222. # elif defined(__BORLANDC__) /* Borland */
  223. # if __BORLANDC__ >= 0x0560
  224. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  225. # else
  226. # define @KWIML@_ABI_SIZEOF_LONG_LONG 0
  227. # endif
  228. # elif defined(_MSC_VER) /* Microsoft */
  229. # if _MSC_VER >= 1310
  230. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  231. # else
  232. # define @KWIML@_ABI_SIZEOF_LONG_LONG 0
  233. # endif
  234. # elif defined(__GNUC__) /* GNU */
  235. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  236. # elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
  237. # define @KWIML@_ABI_SIZEOF_LONG_LONG 8
  238. # endif
  239. #endif
  240. #if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && !defined(@KWIML@_ABI_NO_ERROR_LONG_LONG)
  241. # error "Existence of 'long long' unknown."
  242. #endif
  243. /*--------------------------------------------------------------------------*/
  244. #if !defined(@KWIML@_ABI_SIZEOF___INT64)
  245. # if defined(__INTEL_COMPILER)
  246. # define @KWIML@_ABI_SIZEOF___INT64 8
  247. # elif defined(_MSC_VER)
  248. # define @KWIML@_ABI_SIZEOF___INT64 8
  249. # elif defined(__BORLANDC__)
  250. # define @KWIML@_ABI_SIZEOF___INT64 8
  251. # else
  252. # define @KWIML@_ABI_SIZEOF___INT64 0
  253. # endif
  254. #endif
  255. #if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0
  256. # if @KWIML@_ABI_SIZEOF_LONG == 8
  257. # define @KWIML@_ABI___INT64_IS_LONG 1
  258. # elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  259. # define @KWIML@_ABI___INT64_IS_LONG_LONG 1
  260. # else
  261. # define @KWIML@_ABI___INT64_IS_UNIQUE 1
  262. # endif
  263. #endif
  264. /*--------------------------------------------------------------------------*/
  265. #if !defined(@KWIML@_ABI_SIZEOF_FLOAT)
  266. # if defined(__SIZEOF_FLOAT__)
  267. # define @KWIML@_ABI_SIZEOF_FLOAT __SIZEOF_FLOAT__
  268. # endif
  269. #endif
  270. #if !defined(@KWIML@_ABI_SIZEOF_FLOAT)
  271. # define @KWIML@_ABI_SIZEOF_FLOAT 4
  272. #endif
  273. /*--------------------------------------------------------------------------*/
  274. #if !defined(@KWIML@_ABI_SIZEOF_DOUBLE)
  275. # if defined(__SIZEOF_DOUBLE__)
  276. # define @KWIML@_ABI_SIZEOF_DOUBLE __SIZEOF_DOUBLE__
  277. # endif
  278. #endif
  279. #if !defined(@KWIML@_ABI_SIZEOF_DOUBLE)
  280. # define @KWIML@_ABI_SIZEOF_DOUBLE 8
  281. #endif
  282. /*--------------------------------------------------------------------------*/
  283. /* Identify possible endian cases. The macro @KWIML@_ABI_ENDIAN_ID will be
  284. defined to one of these, or undefined if unknown. */
  285. #if !defined(@KWIML@_ABI_ENDIAN_ID_BIG)
  286. # define @KWIML@_ABI_ENDIAN_ID_BIG 4321
  287. #endif
  288. #if !defined(@KWIML@_ABI_ENDIAN_ID_LITTLE)
  289. # define @KWIML@_ABI_ENDIAN_ID_LITTLE 1234
  290. #endif
  291. #if @KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE
  292. # error "@KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE"
  293. #endif
  294. #if defined(@KWIML@_ABI_ENDIAN_ID) /* Skip #elif cases if already defined. */
  295. /* Use dedicated symbols if the compiler defines them. Do this first
  296. because some architectures allow runtime byte order selection by
  297. the operating system (values for such architectures below are
  298. guesses for compilers that do not define a dedicated symbol).
  299. Ensure that only one is defined in case the platform or a header
  300. defines both as possible values for some third symbol. */
  301. #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
  302. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  303. #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
  304. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  305. #elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
  306. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  307. #elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
  308. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  309. /* Alpha */
  310. #elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
  311. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  312. /* Arm */
  313. #elif defined(__arm__)
  314. # if !defined(__ARMEB__)
  315. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  316. # else
  317. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  318. # endif
  319. /* Intel x86 */
  320. #elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
  321. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  322. #elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
  323. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  324. #elif defined(__MWERKS__) && defined(__INTEL__)
  325. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  326. /* Intel x86-64 */
  327. #elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
  328. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  329. #elif defined(__amd64) || defined(__amd64__)
  330. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  331. /* Intel Architecture-64 (Itanium) */
  332. #elif defined(__ia64) || defined(__ia64__)
  333. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  334. #elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
  335. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  336. /* PowerPC */
  337. #elif defined(__powerpc) || defined(__powerpc__)
  338. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  339. #elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__)
  340. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  341. /* SPARC */
  342. #elif defined(__sparc) || defined(__sparc__)
  343. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  344. /* HP/PA RISC */
  345. #elif defined(__hppa) || defined(__hppa__)
  346. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  347. /* Motorola 68k */
  348. #elif defined(__m68k__) || defined(M68000)
  349. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  350. /* MIPSel (MIPS little endian) */
  351. #elif defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
  352. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  353. /* MIPSeb (MIPS big endian) */
  354. #elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
  355. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  356. /* MIPS (fallback, big endian) */
  357. #elif defined(__mips) || defined(__mips__) || defined(__MIPS__)
  358. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  359. /* OpenRISC 1000 */
  360. #elif defined(__or1k__)
  361. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  362. /* RS/6000 */
  363. #elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER)
  364. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  365. #elif defined(_ARCH_PWR) || defined(_ARCH_PWR2)
  366. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  367. /* System/370 */
  368. #elif defined(__370__) || defined(__THW_370__)
  369. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  370. /* System/390 */
  371. #elif defined(__s390__) || defined(__s390x__)
  372. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  373. /* z/Architecture */
  374. #elif defined(__SYSC_ZARCH__)
  375. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  376. /* VAX */
  377. #elif defined(__vax__)
  378. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  379. /* Aarch64 */
  380. #elif defined(__aarch64__)
  381. # if !defined(__AARCH64EB__)
  382. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  383. # else
  384. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  385. # endif
  386. /* Xtensa */
  387. #elif defined(__XTENSA_EB__)
  388. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG
  389. #elif defined(__XTENSA_EL__)
  390. # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE
  391. /* Unknown CPU */
  392. #elif !defined(@KWIML@_ABI_NO_ERROR_ENDIAN)
  393. # error "Byte order of target CPU unknown."
  394. #endif
  395. /*--------------------------------------------------------------------------*/
  396. #if !defined(@KWIML@_ABI_NO_VERIFY)
  397. #define @KWIML@_ABI__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y]
  398. #define @KWIML@_ABI__VERIFY2(n, x, y) extern int (*n)(x*); extern int (*n)(y*)
  399. #if defined(__cplusplus)
  400. # define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*); extern char* n(y*)
  401. #else
  402. # define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*) /* TODO: possible? */
  403. #endif
  404. #define @KWIML@_ABI__VERIFY_BOOL(m, b) @KWIML@_ABI__VERIFY(m##__VERIFY__, 2, (b)?2:3)
  405. #define @KWIML@_ABI__VERIFY_SIZE(m, t) @KWIML@_ABI__VERIFY(m##__VERIFY__, m, sizeof(t))
  406. #define @KWIML@_ABI__VERIFY_SAME(m, x, y) @KWIML@_ABI__VERIFY2(m##__VERIFY__, x, y)
  407. #define @KWIML@_ABI__VERIFY_DIFF(m, x, y) @KWIML@_ABI__VERIFY3(m##__VERIFY__, x, y)
  408. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DATA_PTR, int*);
  409. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CODE_PTR, int(*)(int));
  410. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CHAR, char);
  411. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_SHORT, short);
  412. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_INT, int);
  413. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG, long);
  414. #if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0
  415. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG_LONG, long long);
  416. #endif
  417. #if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0
  418. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF___INT64, __int64);
  419. #endif
  420. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_FLOAT, float);
  421. @KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DOUBLE, double);
  422. #if defined(@KWIML@_ABI___INT64_IS_LONG)
  423. @KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG, __int64, long);
  424. #elif defined(@KWIML@_ABI___INT64_IS_LONG_LONG)
  425. @KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG_LONG, __int64, long long);
  426. #elif defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0
  427. @KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG, __int64, long);
  428. # if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0
  429. @KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG_LONG, __int64, long long);
  430. # endif
  431. #endif
  432. #if defined(@KWIML@_ABI_CHAR_IS_UNSIGNED)
  433. @KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0);
  434. #elif defined(@KWIML@_ABI_CHAR_IS_SIGNED)
  435. @KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
  436. #endif
  437. #undef @KWIML@_ABI__VERIFY_DIFF
  438. #undef @KWIML@_ABI__VERIFY_SAME
  439. #undef @KWIML@_ABI__VERIFY_SIZE
  440. #undef @KWIML@_ABI__VERIFY_BOOL
  441. #undef @KWIML@_ABI__VERIFY3
  442. #undef @KWIML@_ABI__VERIFY2
  443. #undef @KWIML@_ABI__VERIFY
  444. #endif
  445. #endif