INT.h.in 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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@_INT_H
  29. #define @KWIML@_INT_H
  30. /*
  31. This header defines macros with information about sized integer types.
  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. Input:
  37. @KWIML@_INT_NO_VERIFY = skip verification declarations
  38. @KWIML@_INT_NO_ERROR_INT64_T = type '@KWIML@_INT_int64_t' is optional (*)
  39. @KWIML@_INT_NO_ERROR_UINT64_T = type '@KWIML@_INT_uint64_t' is optional (*)
  40. @KWIML@_INT_NO_ERROR_INTPTR_T = type '@KWIML@_INT_intptr_t' is optional (*)
  41. @KWIML@_INT_NO_ERROR_UINTPTR_T = type '@KWIML@_INT_uintptr_t' is optional (*)
  42. An includer may optionally define the following macros to override defaults.
  43. Either way, an includer may test these macros after inclusion:
  44. @KWIML@_INT_HAVE_STDINT_H = include <stdint.h>
  45. @KWIML@_INT_NO_STDINT_H = do not include <stdint.h>
  46. @KWIML@_INT_HAVE_INTTYPES_H = include <inttypes.h>
  47. @KWIML@_INT_NO_INTTYPES_H = do not include <inttypes.h>
  48. An includer may test the following macros after inclusion:
  49. @KWIML@_INT_HAVE_INT#_T = type 'int#_t' is available
  50. @KWIML@_INT_HAVE_UINT#_T = type 'uint#_t' is available
  51. # = 8, 16, 32, 64, PTR
  52. @KWIML@_INT_int#_t = signed integer type exactly # bits wide
  53. @KWIML@_INT_uint#_t = unsigned integer type exactly # bits wide
  54. # = 8, 16, 32, 64 (*), ptr (*)
  55. @KWIML@_INT_NO_INT64_T = type '@KWIML@_INT_int64_t' not available
  56. @KWIML@_INT_NO_UINT64_T = type '@KWIML@_INT_uint64_t' not available
  57. @KWIML@_INT_NO_INTPTR_T = type '@KWIML@_INT_intptr_t' not available
  58. @KWIML@_INT_NO_UINTPTR_T = type '@KWIML@_INT_uintptr_t' not available
  59. @KWIML@_INT_INT#_C(c) = signed integer constant at least # bits wide
  60. @KWIML@_INT_UINT#_C(c) = unsigned integer constant at least # bits wide
  61. # = 8, 16, 32, 64 (*)
  62. @KWIML@_INT_<fmt># = print or scan format, <fmt> in table below
  63. # = 8, 16, 32, 64, PTR (*)
  64. signed unsigned
  65. ----------- ------------------------------
  66. | decimal | decimal octal hexadecimal |
  67. print | PRId PRIi | PRIu PRIo PRIx PRIX |
  68. scan | SCNd SCNi | SCNu SCNo SCNx |
  69. ----------- ------------------------------
  70. The SCN*8 and SCN*64 format macros will not be defined on systems
  71. with scanf implementations known not to support them.
  72. @KWIML@_INT_BROKEN_INT64_C = macro INT64_C is incorrect if defined
  73. @KWIML@_INT_BROKEN_UINT64_C = macro UINT64_C is incorrect if defined
  74. Some compilers define integer constant macros incorrectly and
  75. cannot handle literals as large as the integer type.
  76. @KWIML@_INT_BROKEN_INT8_T = type 'int8_t' is available but incorrect
  77. Some compilers have a flag to make 'char' (un)signed but do not account
  78. for it while defining int8_t in the non-default case.
  79. The broken cases do not affect correctness of the macros documented above.
  80. */
  81. #include "ABI.h"
  82. /*--------------------------------------------------------------------------*/
  83. #if defined(@KWIML@_INT_HAVE_STDINT_H) /* Already defined. */
  84. #elif defined(@KWIML@_INT_NO_STDINT_H) /* Already defined. */
  85. #elif defined(HAVE_STDINT_H) /* Optionally provided by includer. */
  86. # define @KWIML@_INT_HAVE_STDINT_H 1
  87. #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
  88. # define @KWIML@_INT_HAVE_STDINT_H 1
  89. #elif defined(_MSC_VER) /* MSVC */
  90. # if _MSC_VER >= 1600
  91. # define @KWIML@_INT_HAVE_STDINT_H 1
  92. # else
  93. # define @KWIML@_INT_NO_STDINT_H 1
  94. # endif
  95. #elif defined(__BORLANDC__) /* Borland */
  96. # if __BORLANDC__ >= 0x560
  97. # define @KWIML@_INT_HAVE_STDINT_H 1
  98. # else
  99. # define @KWIML@_INT_NO_STDINT_H 1
  100. # endif
  101. #elif defined(__WATCOMC__) /* Watcom */
  102. # define @KWIML@_INT_NO_STDINT_H 1
  103. #endif
  104. /*--------------------------------------------------------------------------*/
  105. #if defined(@KWIML@_INT_HAVE_INTTYPES_H) /* Already defined. */
  106. #elif defined(@KWIML@_INT_NO_INTTYPES_H) /* Already defined. */
  107. #elif defined(HAVE_INTTYPES_H) /* Optionally provided by includer. */
  108. # define @KWIML@_INT_HAVE_INTTYPES_H 1
  109. #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
  110. # define @KWIML@_INT_HAVE_INTTYPES_H 1
  111. #elif defined(_MSC_VER) /* MSVC */
  112. # define @KWIML@_INT_NO_INTTYPES_H 1
  113. #elif defined(__BORLANDC__) /* Borland */
  114. # define @KWIML@_INT_NO_INTTYPES_H 1
  115. #elif defined(__WATCOMC__) /* Watcom */
  116. # define @KWIML@_INT_NO_INTTYPES_H 1
  117. #else /* Assume it exists. */
  118. # define @KWIML@_INT_HAVE_INTTYPES_H 1
  119. #endif
  120. /*--------------------------------------------------------------------------*/
  121. #if defined(@KWIML@_INT_HAVE_STDINT_H) && defined(@KWIML@_INT_NO_STDINT_H)
  122. # error "Both @KWIML@_INT_HAVE_STDINT_H and @KWIML@_INT_NO_STDINT_H defined!"
  123. #endif
  124. #if defined(@KWIML@_INT_HAVE_INTTYPES_H) && defined(@KWIML@_INT_NO_INTTYPES_H)
  125. # error "Both @KWIML@_INT_HAVE_INTTYPES_H and @KWIML@_INT_NO_INTTYPES_H defined!"
  126. #endif
  127. #if defined(@KWIML@_INT_HAVE_STDINT_H)
  128. # include <stdint.h>
  129. #endif
  130. #if defined(@KWIML@_INT_HAVE_INTTYPES_H)
  131. # if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
  132. # define __STDC_FORMAT_MACROS
  133. # endif
  134. # include <inttypes.h>
  135. #endif
  136. #if defined(@KWIML@_INT_HAVE_STDINT_H) || defined(@KWIML@_INT_HAVE_INTTYPES_H)
  137. #define @KWIML@_INT_HAVE_INT8_T 1
  138. #define @KWIML@_INT_HAVE_UINT8_T 1
  139. #define @KWIML@_INT_HAVE_INT16_T 1
  140. #define @KWIML@_INT_HAVE_UINT16_T 1
  141. #define @KWIML@_INT_HAVE_INT32_T 1
  142. #define @KWIML@_INT_HAVE_UINT32_T 1
  143. #define @KWIML@_INT_HAVE_INT64_T 1
  144. #define @KWIML@_INT_HAVE_UINT64_T 1
  145. #define @KWIML@_INT_HAVE_INTPTR_T 1
  146. #define @KWIML@_INT_HAVE_UINTPTR_T 1
  147. #endif
  148. #if (defined(__SUNPRO_C)||defined(__SUNPRO_CC)) && defined(_CHAR_IS_UNSIGNED)
  149. # define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */
  150. #elif defined(__BORLANDC__) && defined(_CHAR_UNSIGNED)
  151. # define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */
  152. #endif
  153. /*--------------------------------------------------------------------------*/
  154. #if defined(@KWIML@_INT_HAVE_INT8_T) && !defined(@KWIML@_INT_BROKEN_INT8_T)
  155. # define @KWIML@_INT_int8_t int8_t
  156. #else
  157. # define @KWIML@_INT_int8_t signed char
  158. #endif
  159. #if defined(@KWIML@_INT_HAVE_UINT8_T)
  160. # define @KWIML@_INT_uint8_t uint8_t
  161. #else
  162. # define @KWIML@_INT_uint8_t unsigned char
  163. #endif
  164. #if defined(__INTEL_COMPILER)
  165. # if defined(_WIN32)
  166. # define @KWIML@_INT__NO_SCN8
  167. # endif
  168. #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  169. # define @KWIML@_INT__NO_SCN8
  170. #elif defined(__HP_cc) || defined(__HP_aCC)
  171. # define @KWIML@_INT__NO_SCN8
  172. #elif defined(__BORLANDC__)
  173. # define @KWIML@_INT__NO_SCN8
  174. # define @KWIML@_INT__NO_SCN64
  175. #elif defined(_MSC_VER)
  176. # define @KWIML@_INT__NO_SCN8
  177. #elif defined(__WATCOMC__)
  178. # define @KWIML@_INT__NO_SCN8
  179. #endif
  180. /* 8-bit d, i */
  181. #if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRId8)
  182. # define @KWIML@_INT_PRId8 PRId8
  183. #else
  184. # define @KWIML@_INT_PRId8 "d"
  185. #endif
  186. #if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNd8)
  187. # define @KWIML@_INT_SCNd8 SCNd8
  188. #elif !defined(@KWIML@_INT__NO_SCN8)
  189. # define @KWIML@_INT_SCNd8 "hhd"
  190. #endif
  191. #if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRIi8)
  192. # define @KWIML@_INT_PRIi8 PRIi8
  193. #else
  194. # define @KWIML@_INT_PRIi8 "i"
  195. #endif
  196. #if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNi8)
  197. # define @KWIML@_INT_SCNi8 SCNi8
  198. #elif !defined(@KWIML@_INT__NO_SCN8)
  199. # define @KWIML@_INT_SCNi8 "hhi"
  200. #endif
  201. /* 8-bit o, u, x, X */
  202. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIo8)
  203. # define @KWIML@_INT_PRIo8 PRIo8
  204. #else
  205. # define @KWIML@_INT_PRIo8 "o"
  206. #endif
  207. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNo8)
  208. # define @KWIML@_INT_SCNo8 SCNo8
  209. #elif !defined(@KWIML@_INT__NO_SCN8)
  210. # define @KWIML@_INT_SCNo8 "hho"
  211. #endif
  212. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIu8)
  213. # define @KWIML@_INT_PRIu8 PRIu8
  214. #else
  215. # define @KWIML@_INT_PRIu8 "u"
  216. #endif
  217. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNu8)
  218. # define @KWIML@_INT_SCNu8 SCNu8
  219. #elif !defined(@KWIML@_INT__NO_SCN8)
  220. # define @KWIML@_INT_SCNu8 "hhu"
  221. #endif
  222. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIx8)
  223. # define @KWIML@_INT_PRIx8 PRIx8
  224. #else
  225. # define @KWIML@_INT_PRIx8 "x"
  226. #endif
  227. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNx8)
  228. # define @KWIML@_INT_SCNx8 SCNx8
  229. #elif !defined(@KWIML@_INT__NO_SCN8)
  230. # define @KWIML@_INT_SCNx8 "hhx"
  231. #endif
  232. #if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIX8)
  233. # define @KWIML@_INT_PRIX8 PRIX8
  234. #else
  235. # define @KWIML@_INT_PRIX8 "X"
  236. #endif
  237. /* 8-bit constants */
  238. #if defined(INT8_C)
  239. # define @KWIML@_INT_INT8_C(c) INT8_C(c)
  240. #else
  241. # define @KWIML@_INT_INT8_C(c) c
  242. #endif
  243. #if defined(UINT8_C)
  244. # define @KWIML@_INT_UINT8_C(c) UINT8_C(c)
  245. #else
  246. # define @KWIML@_INT_UINT8_C(c) c ## u
  247. #endif
  248. /*--------------------------------------------------------------------------*/
  249. #if defined(@KWIML@_INT_HAVE_INT16_T)
  250. # define @KWIML@_INT_int16_t int16_t
  251. #else
  252. # define @KWIML@_INT_int16_t signed short
  253. #endif
  254. #if defined(@KWIML@_INT_HAVE_UINT16_T)
  255. # define @KWIML@_INT_uint16_t uint16_t
  256. #else
  257. # define @KWIML@_INT_uint16_t unsigned short
  258. #endif
  259. /* 16-bit d, i */
  260. #if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRId16)
  261. # define @KWIML@_INT_PRId16 PRId16
  262. #else
  263. # define @KWIML@_INT_PRId16 "d"
  264. #endif
  265. #if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNd16)
  266. # define @KWIML@_INT_SCNd16 SCNd16
  267. #else
  268. # define @KWIML@_INT_SCNd16 "hd"
  269. #endif
  270. #if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRIi16)
  271. # define @KWIML@_INT_PRIi16 PRIi16
  272. #else
  273. # define @KWIML@_INT_PRIi16 "i"
  274. #endif
  275. #if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNi16)
  276. # define @KWIML@_INT_SCNi16 SCNi16
  277. #else
  278. # define @KWIML@_INT_SCNi16 "hi"
  279. #endif
  280. /* 16-bit o, u, x, X */
  281. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIo16)
  282. # define @KWIML@_INT_PRIo16 PRIo16
  283. #else
  284. # define @KWIML@_INT_PRIo16 "o"
  285. #endif
  286. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNo16)
  287. # define @KWIML@_INT_SCNo16 SCNo16
  288. #else
  289. # define @KWIML@_INT_SCNo16 "ho"
  290. #endif
  291. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIu16)
  292. # define @KWIML@_INT_PRIu16 PRIu16
  293. #else
  294. # define @KWIML@_INT_PRIu16 "u"
  295. #endif
  296. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNu16)
  297. # define @KWIML@_INT_SCNu16 SCNu16
  298. #else
  299. # define @KWIML@_INT_SCNu16 "hu"
  300. #endif
  301. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIx16)
  302. # define @KWIML@_INT_PRIx16 PRIx16
  303. #else
  304. # define @KWIML@_INT_PRIx16 "x"
  305. #endif
  306. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNx16)
  307. # define @KWIML@_INT_SCNx16 SCNx16
  308. #else
  309. # define @KWIML@_INT_SCNx16 "hx"
  310. #endif
  311. #if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIX16)
  312. # define @KWIML@_INT_PRIX16 PRIX16
  313. #else
  314. # define @KWIML@_INT_PRIX16 "X"
  315. #endif
  316. /* 16-bit constants */
  317. #if defined(INT16_C)
  318. # define @KWIML@_INT_INT16_C(c) INT16_C(c)
  319. #else
  320. # define @KWIML@_INT_INT16_C(c) c
  321. #endif
  322. #if defined(UINT16_C)
  323. # define @KWIML@_INT_UINT16_C(c) UINT16_C(c)
  324. #else
  325. # define @KWIML@_INT_UINT16_C(c) c ## u
  326. #endif
  327. /*--------------------------------------------------------------------------*/
  328. #if defined(@KWIML@_INT_HAVE_INT32_T)
  329. # define @KWIML@_INT_int32_t int32_t
  330. #else
  331. # define @KWIML@_INT_int32_t signed int
  332. #endif
  333. #if defined(@KWIML@_INT_HAVE_UINT32_T)
  334. # define @KWIML@_INT_uint32_t uint32_t
  335. #else
  336. # define @KWIML@_INT_uint32_t unsigned int
  337. #endif
  338. /* 32-bit d, i */
  339. #if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRId32)
  340. # define @KWIML@_INT_PRId32 PRId32
  341. #else
  342. # define @KWIML@_INT_PRId32 "d"
  343. #endif
  344. #if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNd32)
  345. # define @KWIML@_INT_SCNd32 SCNd32
  346. #else
  347. # define @KWIML@_INT_SCNd32 "d"
  348. #endif
  349. #if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRIi32)
  350. # define @KWIML@_INT_PRIi32 PRIi32
  351. #else
  352. # define @KWIML@_INT_PRIi32 "i"
  353. #endif
  354. #if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNi32)
  355. # define @KWIML@_INT_SCNi32 SCNi32
  356. #else
  357. # define @KWIML@_INT_SCNi32 "i"
  358. #endif
  359. /* 32-bit o, u, x, X */
  360. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIo32)
  361. # define @KWIML@_INT_PRIo32 PRIo32
  362. #else
  363. # define @KWIML@_INT_PRIo32 "o"
  364. #endif
  365. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNo32)
  366. # define @KWIML@_INT_SCNo32 SCNo32
  367. #else
  368. # define @KWIML@_INT_SCNo32 "o"
  369. #endif
  370. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIu32)
  371. # define @KWIML@_INT_PRIu32 PRIu32
  372. #else
  373. # define @KWIML@_INT_PRIu32 "u"
  374. #endif
  375. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNu32)
  376. # define @KWIML@_INT_SCNu32 SCNu32
  377. #else
  378. # define @KWIML@_INT_SCNu32 "u"
  379. #endif
  380. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIx32)
  381. # define @KWIML@_INT_PRIx32 PRIx32
  382. #else
  383. # define @KWIML@_INT_PRIx32 "x"
  384. #endif
  385. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNx32)
  386. # define @KWIML@_INT_SCNx32 SCNx32
  387. #else
  388. # define @KWIML@_INT_SCNx32 "x"
  389. #endif
  390. #if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIX32)
  391. # define @KWIML@_INT_PRIX32 PRIX32
  392. #else
  393. # define @KWIML@_INT_PRIX32 "X"
  394. #endif
  395. /* 32-bit constants */
  396. #if defined(INT32_C)
  397. # define @KWIML@_INT_INT32_C(c) INT32_C(c)
  398. #else
  399. # define @KWIML@_INT_INT32_C(c) c
  400. #endif
  401. #if defined(UINT32_C)
  402. # define @KWIML@_INT_UINT32_C(c) UINT32_C(c)
  403. #else
  404. # define @KWIML@_INT_UINT32_C(c) c ## u
  405. #endif
  406. /*--------------------------------------------------------------------------*/
  407. #if defined(@KWIML@_INT_HAVE_INT64_T)
  408. # define @KWIML@_INT_int64_t int64_t
  409. #elif @KWIML@_ABI_SIZEOF_LONG == 8
  410. # define @KWIML@_INT_int64_t signed long
  411. #elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  412. # define @KWIML@_INT_int64_t signed long long
  413. #elif defined(@KWIML@_ABI_SIZEOF___INT64)
  414. # define @KWIML@_INT_int64_t signed __int64
  415. #elif defined(@KWIML@_INT_NO_ERROR_INT64_T)
  416. # define @KWIML@_INT_NO_INT64_T
  417. #else
  418. # error "No type known for 'int64_t'."
  419. #endif
  420. #if defined(@KWIML@_INT_HAVE_UINT64_T)
  421. # define @KWIML@_INT_uint64_t uint64_t
  422. #elif @KWIML@_ABI_SIZEOF_LONG == 8
  423. # define @KWIML@_INT_uint64_t unsigned long
  424. #elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  425. # define @KWIML@_INT_uint64_t unsigned long long
  426. #elif defined(@KWIML@_ABI_SIZEOF___INT64)
  427. # define @KWIML@_INT_uint64_t unsigned __int64
  428. #elif defined(@KWIML@_INT_NO_ERROR_UINT64_T)
  429. # define @KWIML@_INT_NO_UINT64_T
  430. #else
  431. # error "No type known for 'uint64_t'."
  432. #endif
  433. #if defined(__INTEL_COMPILER)
  434. #elif defined(__BORLANDC__)
  435. # define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */
  436. # define @KWIML@_INT_BROKEN_INT64_C /* system macro defined incorrectly */
  437. # define @KWIML@_INT_BROKEN_UINT64_C /* system macro defined incorrectly */
  438. #elif defined(_MSC_VER) && _MSC_VER < 1400
  439. # define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */
  440. #endif
  441. #if @KWIML@_ABI_SIZEOF_LONG == 8
  442. # define @KWIML@_INT__FMT64 "l"
  443. #elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  444. # if !defined(@KWIML@_INT__NO_FMTLL)
  445. # define @KWIML@_INT__FMT64 "ll"
  446. # else
  447. # define @KWIML@_INT__FMT64 "I64"
  448. # endif
  449. #elif defined(@KWIML@_ABI_SIZEOF___INT64)
  450. # if defined(__BORLANDC__)
  451. # define @KWIML@_INT__FMT64 "L"
  452. # else
  453. # define @KWIML@_INT__FMT64 "I64"
  454. # endif
  455. #endif
  456. /* 64-bit d, i */
  457. #if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRId64)
  458. # define @KWIML@_INT_PRId64 PRId64
  459. #elif defined(@KWIML@_INT__FMT64)
  460. # define @KWIML@_INT_PRId64 @KWIML@_INT__FMT64 "d"
  461. #endif
  462. #if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNd64)
  463. # define @KWIML@_INT_SCNd64 SCNd64
  464. #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64)
  465. # define @KWIML@_INT_SCNd64 @KWIML@_INT__FMT64 "d"
  466. #endif
  467. #if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRIi64)
  468. # define @KWIML@_INT_PRIi64 PRIi64
  469. #elif defined(@KWIML@_INT__FMT64)
  470. # define @KWIML@_INT_PRIi64 @KWIML@_INT__FMT64 "d"
  471. #endif
  472. #if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNi64)
  473. # define @KWIML@_INT_SCNi64 SCNi64
  474. #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64)
  475. # define @KWIML@_INT_SCNi64 @KWIML@_INT__FMT64 "d"
  476. #endif
  477. /* 64-bit o, u, x, X */
  478. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIo64)
  479. # define @KWIML@_INT_PRIo64 PRIo64
  480. #elif defined(@KWIML@_INT__FMT64)
  481. # define @KWIML@_INT_PRIo64 @KWIML@_INT__FMT64 "o"
  482. #endif
  483. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNo64)
  484. # define @KWIML@_INT_SCNo64 SCNo64
  485. #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64)
  486. # define @KWIML@_INT_SCNo64 @KWIML@_INT__FMT64 "o"
  487. #endif
  488. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIu64)
  489. # define @KWIML@_INT_PRIu64 PRIu64
  490. #elif defined(@KWIML@_INT__FMT64)
  491. # define @KWIML@_INT_PRIu64 @KWIML@_INT__FMT64 "u"
  492. #endif
  493. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNu64)
  494. # define @KWIML@_INT_SCNu64 SCNu64
  495. #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64)
  496. # define @KWIML@_INT_SCNu64 @KWIML@_INT__FMT64 "u"
  497. #endif
  498. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIx64)
  499. # define @KWIML@_INT_PRIx64 PRIx64
  500. #elif defined(@KWIML@_INT__FMT64)
  501. # define @KWIML@_INT_PRIx64 @KWIML@_INT__FMT64 "x"
  502. #endif
  503. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNx64)
  504. # define @KWIML@_INT_SCNx64 SCNx64
  505. #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64)
  506. # define @KWIML@_INT_SCNx64 @KWIML@_INT__FMT64 "x"
  507. #endif
  508. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIX64)
  509. # define @KWIML@_INT_PRIX64 PRIX64
  510. #elif defined(@KWIML@_INT__FMT64)
  511. # define @KWIML@_INT_PRIX64 @KWIML@_INT__FMT64 "X"
  512. #endif
  513. /* 64-bit constants */
  514. #if defined(@KWIML@_INT_HAVE_INT64_T) && defined(INT64_C) \
  515. && !defined(@KWIML@_INT_BROKEN_INT64_C)
  516. # define @KWIML@_INT_INT64_C(c) INT64_C(c)
  517. #elif @KWIML@_ABI_SIZEOF_LONG == 8
  518. # define @KWIML@_INT_INT64_C(c) c ## l
  519. #elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  520. # define @KWIML@_INT_INT64_C(c) c ## ll
  521. #elif defined(@KWIML@_ABI_SIZEOF___INT64)
  522. # define @KWIML@_INT_INT64_C(c) c ## i64
  523. #endif
  524. #if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(UINT64_C) \
  525. && !defined(@KWIML@_INT_BROKEN_UINT64_C)
  526. # define @KWIML@_INT_UINT64_C(c) UINT64_C(c)
  527. #elif @KWIML@_ABI_SIZEOF_LONG == 8
  528. # define @KWIML@_INT_UINT64_C(c) c ## ul
  529. #elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8
  530. # define @KWIML@_INT_UINT64_C(c) c ## ull
  531. #elif defined(@KWIML@_ABI_SIZEOF___INT64)
  532. # define @KWIML@_INT_UINT64_C(c) c ## ui64
  533. #endif
  534. /*--------------------------------------------------------------------------*/
  535. #if defined(@KWIML@_INT_HAVE_INTPTR_T)
  536. # define @KWIML@_INT_intptr_t intptr_t
  537. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  538. # define @KWIML@_INT_intptr_t @KWIML@_INT_int32_t
  539. #elif !defined(@KWIML@_INT_NO_INT64_T)
  540. # define @KWIML@_INT_intptr_t @KWIML@_INT_int64_t
  541. #elif defined(@KWIML@_INT_NO_ERROR_INTPTR_T)
  542. # define @KWIML@_INT_NO_INTPTR_T
  543. #else
  544. # error "No type known for 'intptr_t'."
  545. #endif
  546. #if defined(@KWIML@_INT_HAVE_UINTPTR_T)
  547. # define @KWIML@_INT_uintptr_t uintptr_t
  548. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  549. # define @KWIML@_INT_uintptr_t @KWIML@_INT_uint32_t
  550. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  551. # define @KWIML@_INT_uintptr_t @KWIML@_INT_uint64_t
  552. #elif defined(@KWIML@_INT_NO_ERROR_UINTPTR_T)
  553. # define @KWIML@_INT_NO_UINTPTR_T
  554. #else
  555. # error "No type known for 'uintptr_t'."
  556. #endif
  557. #if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIdPTR)
  558. # define @KWIML@_INT_PRIdPTR PRIdPTR
  559. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  560. # define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId32
  561. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  562. # define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId64
  563. #endif
  564. #if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNdPTR)
  565. # define @KWIML@_INT_SCNdPTR SCNdPTR
  566. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  567. # define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd32
  568. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  569. # define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd64
  570. #endif
  571. #if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIiPTR)
  572. # define @KWIML@_INT_PRIiPTR PRIiPTR
  573. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  574. # define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi32
  575. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  576. # define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi64
  577. #endif
  578. #if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNiPTR)
  579. # define @KWIML@_INT_SCNiPTR SCNiPTR
  580. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  581. # define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi32
  582. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  583. # define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi64
  584. #endif
  585. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIoPTR)
  586. # define @KWIML@_INT_PRIoPTR PRIoPTR
  587. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  588. # define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo32
  589. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  590. # define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo64
  591. #endif
  592. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNoPTR)
  593. # define @KWIML@_INT_SCNoPTR SCNoPTR
  594. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  595. # define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo32
  596. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  597. # define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo64
  598. #endif
  599. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIuPTR)
  600. # define @KWIML@_INT_PRIuPTR PRIuPTR
  601. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  602. # define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu32
  603. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  604. # define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu64
  605. #endif
  606. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNuPTR)
  607. # define @KWIML@_INT_SCNuPTR SCNuPTR
  608. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  609. # define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu32
  610. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  611. # define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu64
  612. #endif
  613. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIxPTR)
  614. # define @KWIML@_INT_PRIxPTR PRIxPTR
  615. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  616. # define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx32
  617. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  618. # define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx64
  619. #endif
  620. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNxPTR)
  621. # define @KWIML@_INT_SCNxPTR SCNxPTR
  622. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  623. # define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx32
  624. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  625. # define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx64
  626. #endif
  627. #if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIXPTR)
  628. # define @KWIML@_INT_PRIXPTR PRIXPTR
  629. #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4
  630. # define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX32
  631. #elif !defined(@KWIML@_INT_NO_UINT64_T)
  632. # define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX64
  633. #endif
  634. /*--------------------------------------------------------------------------*/
  635. #if !defined(@KWIML@_INT_NO_VERIFY)
  636. #define @KWIML@_INT__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y]
  637. #define @KWIML@_INT__VERIFY_BOOL(m, b) @KWIML@_INT__VERIFY(m##__VERIFY__, 2, (b)?2:3)
  638. #define @KWIML@_INT__VERIFY_TYPE(t, s) @KWIML@_INT__VERIFY(t##__VERIFY__, s, sizeof(t))
  639. #define @KWIML@_INT__VERIFY_SIGN(t, u, o) @KWIML@_INT__VERIFY_BOOL(t##__SIGN, (t)((u)1 << ((sizeof(t)<<3)-1)) o 0)
  640. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int8_t, 1);
  641. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint8_t, 1);
  642. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int16_t, 2);
  643. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint16_t, 2);
  644. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int32_t, 4);
  645. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint32_t, 4);
  646. #if !defined(@KWIML@_INT_NO_INT64_T)
  647. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int64_t, 8);
  648. #endif
  649. #if !defined(@KWIML@_INT_NO_UINT64_T)
  650. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint64_t, 8);
  651. #endif
  652. #if !defined(@KWIML@_INT_NO_INTPTR_T)
  653. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_intptr_t, sizeof(void*));
  654. #endif
  655. #if !defined(@KWIML@_INT_NO_UINTPTR_T)
  656. @KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uintptr_t, sizeof(void*));
  657. #endif
  658. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int8_t, @KWIML@_INT_uint8_t, <);
  659. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint8_t, @KWIML@_INT_uint8_t, >);
  660. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int16_t, @KWIML@_INT_uint16_t, <);
  661. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint16_t, @KWIML@_INT_uint16_t, >);
  662. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int32_t, @KWIML@_INT_uint32_t, <);
  663. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint32_t, @KWIML@_INT_uint32_t, >);
  664. #if !defined(@KWIML@_INT_NO_INT64_T)
  665. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int64_t, @KWIML@_INT_uint64_t, <);
  666. #endif
  667. #if !defined(@KWIML@_INT_NO_UINT64_T)
  668. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint64_t, @KWIML@_INT_uint64_t, >);
  669. #endif
  670. #if !defined(@KWIML@_INT_NO_INTPTR_T)
  671. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_intptr_t, @KWIML@_INT_uintptr_t, <);
  672. #endif
  673. #if !defined(@KWIML@_INT_NO_UINTPTR_T)
  674. @KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uintptr_t, @KWIML@_INT_uintptr_t, >);
  675. #endif
  676. #undef @KWIML@_INT__VERIFY_SIGN
  677. #undef @KWIML@_INT__VERIFY_TYPE
  678. #undef @KWIML@_INT__VERIFY_BOOL
  679. #undef @KWIML@_INT__VERIFY
  680. #endif
  681. #endif