ax_create_stdint_h.m4 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. dnl Taken from ac-archive ac-archive-5 module's CVS HEAD
  2. dnl ac-archive is available at http://ac-archive.sf.net
  3. dnl URL of WebCVS of this m4 macros is:
  4. dnl http://cvs.sourceforge.net/viewcvs.py/ac-archive/ac-archive-5/guidod/
  5. dnl
  6. dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
  7. dnl
  8. dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
  9. dnl existence of an include file <stdint.h> that defines a set of
  10. dnl typedefs, especially uint8_t,int32_t,uintptr_t. Many older
  11. dnl installations will not provide this file, but some will have the
  12. dnl very same definitions in <inttypes.h>. In other enviroments we can
  13. dnl use the inet-types in <sys/types.h> which would define the typedefs
  14. dnl int8_t and u_int8_t respectivly.
  15. dnl
  16. dnl This macros will create a local "_stdint.h" or the headerfile given
  17. dnl as an argument. In many cases that file will just "#include
  18. dnl <stdint.h>" or "#include <inttypes.h>", while in other environments
  19. dnl it will provide the set of basic 'stdint's definitions/typedefs:
  20. dnl
  21. dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
  22. dnl int_least32_t.. int_fast32_t.. intmax_t
  23. dnl
  24. dnl which may or may not rely on the definitions of other files, or
  25. dnl using the AC_CHECK_SIZEOF macro to determine the actual sizeof each
  26. dnl type.
  27. dnl
  28. dnl if your header files require the stdint-types you will want to
  29. dnl create an installable file mylib-int.h that all your other
  30. dnl installable header may include. So if you have a library package
  31. dnl named "mylib", just use
  32. dnl
  33. dnl AX_CREATE_STDINT_H(mylib-int.h)
  34. dnl
  35. dnl in configure.ac and go to install that very header file in
  36. dnl Makefile.am along with the other headers (mylib.h) - and the
  37. dnl mylib-specific headers can simply use "#include <mylib-int.h>" to
  38. dnl obtain the stdint-types.
  39. dnl
  40. dnl Remember, if the system already had a valid <stdint.h>, the
  41. dnl generated file will include it directly. No need for fuzzy
  42. dnl HAVE_STDINT_H things...
  43. dnl
  44. dnl @category C
  45. dnl @author Guido Draheim <guidod@gmx.de>
  46. dnl @version 2003-12-07
  47. dnl @license GPLWithACException
  48. AC_DEFUN([AX_CHECK_DATA_MODEL],[
  49. AC_CHECK_SIZEOF(char)
  50. AC_CHECK_SIZEOF(short)
  51. AC_CHECK_SIZEOF(int)
  52. AC_CHECK_SIZEOF(long)
  53. AC_CHECK_SIZEOF(void*)
  54. ac_cv_char_data_model=""
  55. ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
  56. ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
  57. ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
  58. ac_cv_long_data_model=""
  59. ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
  60. ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
  61. ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
  62. AC_MSG_CHECKING([data model])
  63. case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
  64. 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;;
  65. 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;;
  66. 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;;
  67. 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
  68. 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;;
  69. 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
  70. 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;;
  71. 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
  72. 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;;
  73. 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
  74. 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
  75. 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
  76. 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
  77. 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
  78. 222/*|333/*|444/*|666/*|888/*) :
  79. ac_cv_data_model="iDSP" ; n="unusual dsptype" ;;
  80. *) ac_cv_data_model="none" ; n="very unusual model" ;;
  81. esac
  82. AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
  83. ])
  84. dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
  85. AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
  86. AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
  87. ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
  88. AC_MSG_RESULT([(..)])
  89. for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do
  90. unset ac_cv_type_uintptr_t
  91. unset ac_cv_type_uint64_t
  92. AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
  93. AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
  94. m4_ifvaln([$1],[$1]) break
  95. done
  96. AC_MSG_CHECKING([for stdint uintptr_t])
  97. ])
  98. ])
  99. AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
  100. AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
  101. ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
  102. AC_MSG_RESULT([(..)])
  103. for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do
  104. unset ac_cv_type_uint32_t
  105. unset ac_cv_type_uint64_t
  106. AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
  107. AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
  108. m4_ifvaln([$1],[$1]) break
  109. break;
  110. done
  111. AC_MSG_CHECKING([for stdint uint32_t])
  112. ])
  113. ])
  114. AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
  115. AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
  116. ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
  117. AC_MSG_RESULT([(..)])
  118. for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
  119. unset ac_cv_type_u_int32_t
  120. unset ac_cv_type_u_int64_t
  121. AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
  122. AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
  123. m4_ifvaln([$1],[$1]) break
  124. break;
  125. done
  126. AC_MSG_CHECKING([for stdint u_int32_t])
  127. ])
  128. ])
  129. AC_DEFUN([AX_CREATE_STDINT_H],
  130. [# ------ AX CREATE STDINT H -------------------------------------
  131. AC_MSG_CHECKING([for stdint types])
  132. ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
  133. # try to shortcircuit - if the default include path of the compiler
  134. # can find a "stdint.h" header then we assume that all compilers can.
  135. AC_CACHE_VAL([ac_cv_header_stdint_t],[
  136. old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
  137. old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
  138. old_CFLAGS="$CFLAGS" ; CFLAGS=""
  139. AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
  140. [ac_cv_stdint_result="(assuming C99 compatible system)"
  141. ac_cv_header_stdint_t="stdint.h"; ],
  142. [ac_cv_header_stdint_t=""])
  143. CXXFLAGS="$old_CXXFLAGS"
  144. CPPFLAGS="$old_CPPFLAGS"
  145. CFLAGS="$old_CFLAGS" ])
  146. v="... $ac_cv_header_stdint_h"
  147. if test "$ac_stdint_h" = "stdint.h" ; then
  148. AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
  149. elif test "$ac_stdint_h" = "inttypes.h" ; then
  150. AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
  151. elif test "_$ac_cv_header_stdint_t" = "_" ; then
  152. AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
  153. else
  154. ac_cv_header_stdint="$ac_cv_header_stdint_t"
  155. AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
  156. fi
  157. if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
  158. dnl .....intro message done, now do a few system checks.....
  159. dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type,
  160. dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW
  161. dnl instead that is triggered with 3 or more arguments (see types.m4)
  162. inttype_headers=`echo $2 | sed -e 's/,/ /g'`
  163. ac_cv_stdint_result="(no helpful system typedefs seen)"
  164. AX_CHECK_HEADER_STDINT_X(dnl
  165. stdint.h inttypes.h sys/inttypes.h $inttype_headers,
  166. ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
  167. if test "_$ac_cv_header_stdint_x" = "_" ; then
  168. AX_CHECK_HEADER_STDINT_O(dnl,
  169. inttypes.h sys/inttypes.h stdint.h $inttype_headers,
  170. ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
  171. fi
  172. if test "_$ac_cv_header_stdint_x" = "_" ; then
  173. if test "_$ac_cv_header_stdint_o" = "_" ; then
  174. AX_CHECK_HEADER_STDINT_U(dnl,
  175. sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
  176. ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
  177. fi fi
  178. dnl if there was no good C99 header file, do some typedef checks...
  179. if test "_$ac_cv_header_stdint_x" = "_" ; then
  180. AC_MSG_CHECKING([for stdint datatype model])
  181. AC_MSG_RESULT([(..)])
  182. AX_CHECK_DATA_MODEL
  183. fi
  184. if test "_$ac_cv_header_stdint_x" != "_" ; then
  185. ac_cv_header_stdint="$ac_cv_header_stdint_x"
  186. elif test "_$ac_cv_header_stdint_o" != "_" ; then
  187. ac_cv_header_stdint="$ac_cv_header_stdint_o"
  188. elif test "_$ac_cv_header_stdint_u" != "_" ; then
  189. ac_cv_header_stdint="$ac_cv_header_stdint_u"
  190. else
  191. ac_cv_header_stdint="stddef.h"
  192. fi
  193. AC_MSG_CHECKING([for extra inttypes in chosen header])
  194. AC_MSG_RESULT([($ac_cv_header_stdint)])
  195. dnl see if int_least and int_fast types are present in _this_ header.
  196. unset ac_cv_type_int_least32_t
  197. unset ac_cv_type_int_fast32_t
  198. AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
  199. AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
  200. AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
  201. fi # shortcircut to system "stdint.h"
  202. # ------------------ PREPARE VARIABLES ------------------------------
  203. if test "$GCC" = "yes" ; then
  204. ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
  205. else
  206. ac_cv_stdint_message="using $CC"
  207. fi
  208. AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
  209. $ac_cv_stdint_result])
  210. dnl -----------------------------------------------------------------
  211. # ----------------- DONE inttypes.h checks START header -------------
  212. AC_CONFIG_COMMANDS([$ac_stdint_h],[
  213. AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
  214. ac_stdint=$tmp/_stdint.h
  215. echo "#ifndef" $_ac_stdint_h >$ac_stdint
  216. echo "#define" $_ac_stdint_h "1" >>$ac_stdint
  217. echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
  218. echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
  219. echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
  220. if test "_$ac_cv_header_stdint_t" != "_" ; then
  221. echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
  222. echo "#include <stdint.h>" >>$ac_stdint
  223. echo "#endif" >>$ac_stdint
  224. echo "#endif" >>$ac_stdint
  225. else
  226. cat >>$ac_stdint <<STDINT_EOF
  227. /* ................... shortcircuit part ........................... */
  228. #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
  229. #include <stdint.h>
  230. #else
  231. #include <stddef.h>
  232. /* .................... configured part ............................ */
  233. STDINT_EOF
  234. echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
  235. if test "_$ac_cv_header_stdint_x" != "_" ; then
  236. ac_header="$ac_cv_header_stdint_x"
  237. echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
  238. else
  239. echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
  240. fi
  241. echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
  242. if test "_$ac_cv_header_stdint_o" != "_" ; then
  243. ac_header="$ac_cv_header_stdint_o"
  244. echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
  245. else
  246. echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
  247. fi
  248. echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
  249. if test "_$ac_cv_header_stdint_u" != "_" ; then
  250. ac_header="$ac_cv_header_stdint_u"
  251. echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
  252. else
  253. echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
  254. fi
  255. echo "" >>$ac_stdint
  256. if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
  257. echo "#include <$ac_header>" >>$ac_stdint
  258. echo "" >>$ac_stdint
  259. fi fi
  260. echo "/* which 64bit typedef has been found */" >>$ac_stdint
  261. if test "$ac_cv_type_uint64_t" = "yes" ; then
  262. echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
  263. else
  264. echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
  265. fi
  266. if test "$ac_cv_type_u_int64_t" = "yes" ; then
  267. echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
  268. else
  269. echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
  270. fi
  271. echo "" >>$ac_stdint
  272. echo "/* which type model has been detected */" >>$ac_stdint
  273. if test "_$ac_cv_char_data_model" != "_" ; then
  274. echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
  275. echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
  276. else
  277. echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
  278. echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
  279. fi
  280. echo "" >>$ac_stdint
  281. echo "/* whether int_least types were detected */" >>$ac_stdint
  282. if test "$ac_cv_type_int_least32_t" = "yes"; then
  283. echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
  284. else
  285. echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
  286. fi
  287. echo "/* whether int_fast types were detected */" >>$ac_stdint
  288. if test "$ac_cv_type_int_fast32_t" = "yes"; then
  289. echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
  290. else
  291. echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
  292. fi
  293. echo "/* whether intmax_t type was detected */" >>$ac_stdint
  294. if test "$ac_cv_type_intmax_t" = "yes"; then
  295. echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
  296. else
  297. echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
  298. fi
  299. echo "" >>$ac_stdint
  300. cat >>$ac_stdint <<STDINT_EOF
  301. /* .................... detections part ............................ */
  302. /* whether we need to define bitspecific types from compiler base types */
  303. #ifndef _STDINT_HEADER_INTPTR
  304. #ifndef _STDINT_HEADER_UINT32
  305. #ifndef _STDINT_HEADER_U_INT32
  306. #define _STDINT_NEED_INT_MODEL_T
  307. #else
  308. #define _STDINT_HAVE_U_INT_TYPES
  309. #endif
  310. #endif
  311. #endif
  312. #ifdef _STDINT_HAVE_U_INT_TYPES
  313. #undef _STDINT_NEED_INT_MODEL_T
  314. #endif
  315. #ifdef _STDINT_CHAR_MODEL
  316. #if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
  317. #ifndef _STDINT_BYTE_MODEL
  318. #define _STDINT_BYTE_MODEL 12
  319. #endif
  320. #endif
  321. #endif
  322. #ifndef _STDINT_HAVE_INT_LEAST32_T
  323. #define _STDINT_NEED_INT_LEAST_T
  324. #endif
  325. #ifndef _STDINT_HAVE_INT_FAST32_T
  326. #define _STDINT_NEED_INT_FAST_T
  327. #endif
  328. #ifndef _STDINT_HEADER_INTPTR
  329. #define _STDINT_NEED_INTPTR_T
  330. #ifndef _STDINT_HAVE_INTMAX_T
  331. #define _STDINT_NEED_INTMAX_T
  332. #endif
  333. #endif
  334. /* .................... definition part ............................ */
  335. /* some system headers have good uint64_t */
  336. #ifndef _HAVE_UINT64_T
  337. #if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
  338. #define _HAVE_UINT64_T
  339. #elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
  340. #define _HAVE_UINT64_T
  341. typedef u_int64_t uint64_t;
  342. #endif
  343. #endif
  344. #ifndef _HAVE_UINT64_T
  345. /* .. here are some common heuristics using compiler runtime specifics */
  346. #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
  347. #define _HAVE_UINT64_T
  348. #define _HAVE_LONGLONG_UINT64_T
  349. typedef long long int64_t;
  350. typedef unsigned long long uint64_t;
  351. #elif !defined __STRICT_ANSI__
  352. #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
  353. #define _HAVE_UINT64_T
  354. typedef __int64 int64_t;
  355. typedef unsigned __int64 uint64_t;
  356. #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
  357. /* note: all ELF-systems seem to have loff-support which needs 64-bit */
  358. #if !defined _NO_LONGLONG
  359. #define _HAVE_UINT64_T
  360. #define _HAVE_LONGLONG_UINT64_T
  361. typedef long long int64_t;
  362. typedef unsigned long long uint64_t;
  363. #endif
  364. #elif defined __alpha || (defined __mips && defined _ABIN32)
  365. #if !defined _NO_LONGLONG
  366. typedef long int64_t;
  367. typedef unsigned long uint64_t;
  368. #endif
  369. /* compiler/cpu type to define int64_t */
  370. #endif
  371. #endif
  372. #endif
  373. #if defined _STDINT_HAVE_U_INT_TYPES
  374. /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
  375. typedef u_int8_t uint8_t;
  376. typedef u_int16_t uint16_t;
  377. typedef u_int32_t uint32_t;
  378. /* glibc compatibility */
  379. #ifndef __int8_t_defined
  380. #define __int8_t_defined
  381. #endif
  382. #endif
  383. #ifdef _STDINT_NEED_INT_MODEL_T
  384. /* we must guess all the basic types. Apart from byte-adressable system, */
  385. /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
  386. /* (btw, those nibble-addressable systems are way off, or so we assume) */
  387. dnl /* have a look at "64bit and data size neutrality" at */
  388. dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
  389. dnl /* (the shorthand "ILP" types always have a "P" part) */
  390. #if defined _STDINT_BYTE_MODEL
  391. #if _STDINT_LONG_MODEL+0 == 242
  392. /* 2:4:2 = IP16 = a normal 16-bit system */
  393. typedef unsigned char uint8_t;
  394. typedef unsigned short uint16_t;
  395. typedef unsigned long uint32_t;
  396. #ifndef __int8_t_defined
  397. #define __int8_t_defined
  398. typedef char int8_t;
  399. typedef short int16_t;
  400. typedef long int32_t;
  401. #endif
  402. #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
  403. /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
  404. /* 4:4:4 = ILP32 = a normal 32-bit system */
  405. typedef unsigned char uint8_t;
  406. typedef unsigned short uint16_t;
  407. typedef unsigned int uint32_t;
  408. #ifndef __int8_t_defined
  409. #define __int8_t_defined
  410. typedef char int8_t;
  411. typedef short int16_t;
  412. typedef int int32_t;
  413. #endif
  414. #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
  415. /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
  416. /* 4:8:8 = LP64 = a normal 64-bit system */
  417. typedef unsigned char uint8_t;
  418. typedef unsigned short uint16_t;
  419. typedef unsigned int uint32_t;
  420. #ifndef __int8_t_defined
  421. #define __int8_t_defined
  422. typedef char int8_t;
  423. typedef short int16_t;
  424. typedef int int32_t;
  425. #endif
  426. /* this system has a "long" of 64bit */
  427. #ifndef _HAVE_UINT64_T
  428. #define _HAVE_UINT64_T
  429. typedef unsigned long uint64_t;
  430. typedef long int64_t;
  431. #endif
  432. #elif _STDINT_LONG_MODEL+0 == 448
  433. /* LLP64 a 64-bit system derived from a 32-bit system */
  434. typedef unsigned char uint8_t;
  435. typedef unsigned short uint16_t;
  436. typedef unsigned int uint32_t;
  437. #ifndef __int8_t_defined
  438. #define __int8_t_defined
  439. typedef char int8_t;
  440. typedef short int16_t;
  441. typedef int int32_t;
  442. #endif
  443. /* assuming the system has a "long long" */
  444. #ifndef _HAVE_UINT64_T
  445. #define _HAVE_UINT64_T
  446. #define _HAVE_LONGLONG_UINT64_T
  447. typedef unsigned long long uint64_t;
  448. typedef long long int64_t;
  449. #endif
  450. #else
  451. #define _STDINT_NO_INT32_T
  452. #endif
  453. #else
  454. #define _STDINT_NO_INT8_T
  455. #define _STDINT_NO_INT32_T
  456. #endif
  457. #endif
  458. /*
  459. * quote from SunOS-5.8 sys/inttypes.h:
  460. * Use at your own risk. As of February 1996, the committee is squarely
  461. * behind the fixed sized types; the "least" and "fast" types are still being
  462. * discussed. The probability that the "fast" types may be removed before
  463. * the standard is finalized is high enough that they are not currently
  464. * implemented.
  465. */
  466. #if defined _STDINT_NEED_INT_LEAST_T
  467. typedef int8_t int_least8_t;
  468. typedef int16_t int_least16_t;
  469. typedef int32_t int_least32_t;
  470. #ifdef _HAVE_UINT64_T
  471. typedef int64_t int_least64_t;
  472. #endif
  473. typedef uint8_t uint_least8_t;
  474. typedef uint16_t uint_least16_t;
  475. typedef uint32_t uint_least32_t;
  476. #ifdef _HAVE_UINT64_T
  477. typedef uint64_t uint_least64_t;
  478. #endif
  479. /* least types */
  480. #endif
  481. #if defined _STDINT_NEED_INT_FAST_T
  482. typedef int8_t int_fast8_t;
  483. typedef int int_fast16_t;
  484. typedef int32_t int_fast32_t;
  485. #ifdef _HAVE_UINT64_T
  486. typedef int64_t int_fast64_t;
  487. #endif
  488. typedef uint8_t uint_fast8_t;
  489. typedef unsigned uint_fast16_t;
  490. typedef uint32_t uint_fast32_t;
  491. #ifdef _HAVE_UINT64_T
  492. typedef uint64_t uint_fast64_t;
  493. #endif
  494. /* fast types */
  495. #endif
  496. #ifdef _STDINT_NEED_INTMAX_T
  497. #ifdef _HAVE_UINT64_T
  498. typedef int64_t intmax_t;
  499. typedef uint64_t uintmax_t;
  500. #else
  501. typedef long intmax_t;
  502. typedef unsigned long uintmax_t;
  503. #endif
  504. #endif
  505. #ifdef _STDINT_NEED_INTPTR_T
  506. #ifndef __intptr_t_defined
  507. #define __intptr_t_defined
  508. /* we encourage using "long" to store pointer values, never use "int" ! */
  509. #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
  510. typedef unsigned int uintptr_t;
  511. typedef int intptr_t;
  512. #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
  513. typedef unsigned long uintptr_t;
  514. typedef long intptr_t;
  515. #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
  516. typedef uint64_t uintptr_t;
  517. typedef int64_t intptr_t;
  518. #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
  519. typedef unsigned long uintptr_t;
  520. typedef long intptr_t;
  521. #endif
  522. #endif
  523. #endif
  524. /* The ISO C99 standard specifies that in C++ implementations these
  525. should only be defined if explicitly requested. */
  526. #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
  527. #ifndef UINT32_C
  528. /* Signed. */
  529. # define INT8_C(c) c
  530. # define INT16_C(c) c
  531. # define INT32_C(c) c
  532. # ifdef _HAVE_LONGLONG_UINT64_T
  533. # define INT64_C(c) c ## L
  534. # else
  535. # define INT64_C(c) c ## LL
  536. # endif
  537. /* Unsigned. */
  538. # define UINT8_C(c) c ## U
  539. # define UINT16_C(c) c ## U
  540. # define UINT32_C(c) c ## U
  541. # ifdef _HAVE_LONGLONG_UINT64_T
  542. # define UINT64_C(c) c ## UL
  543. # else
  544. # define UINT64_C(c) c ## ULL
  545. # endif
  546. /* Maximal type. */
  547. # ifdef _HAVE_LONGLONG_UINT64_T
  548. # define INTMAX_C(c) c ## L
  549. # define UINTMAX_C(c) c ## UL
  550. # else
  551. # define INTMAX_C(c) c ## LL
  552. # define UINTMAX_C(c) c ## ULL
  553. # endif
  554. /* literalnumbers */
  555. #endif
  556. #endif
  557. /* These limits are merily those of a two complement byte-oriented system */
  558. /* Minimum of signed integral types. */
  559. #ifndef INT8_MIN
  560. # define INT8_MIN (-128)
  561. #endif
  562. #ifndef INT16_MIN
  563. # define INT16_MIN (-32767-1)
  564. #endif
  565. #ifndef INT32_MIN
  566. # define INT32_MIN (-2147483647-1)
  567. #endif
  568. #ifndef INT64_MIN
  569. # define INT64_MIN (-__INT64_C(9223372036854775807)-1)
  570. #endif
  571. /* Maximum of signed integral types. */
  572. #ifndef INT8_MAX
  573. # define INT8_MAX (127)
  574. #endif
  575. #ifndef INT16_MAX
  576. # define INT16_MAX (32767)
  577. #endif
  578. #ifndef INT32_MAX
  579. # define INT32_MAX (2147483647)
  580. #endif
  581. #ifndef INT64_MAX
  582. # define INT64_MAX (__INT64_C(9223372036854775807))
  583. #endif
  584. /* Maximum of unsigned integral types. */
  585. #ifndef UINT8_MAX
  586. # define UINT8_MAX (255)
  587. #endif
  588. #ifndef UINT16_MAX
  589. # define UINT16_MAX (65535)
  590. #endif
  591. #ifndef UINT32_MAX
  592. # define UINT32_MAX (4294967295U)
  593. #endif
  594. #ifndef UINT64_MAX
  595. # define UINT64_MAX (__UINT64_C(18446744073709551615))
  596. #endif
  597. /* Minimum of signed integral types having a minimum size. */
  598. # define INT_LEAST8_MIN INT8_MIN
  599. # define INT_LEAST16_MIN INT16_MIN
  600. # define INT_LEAST32_MIN INT32_MIN
  601. # define INT_LEAST64_MIN INT64_MIN
  602. /* Maximum of signed integral types having a minimum size. */
  603. # define INT_LEAST8_MAX INT8_MAX
  604. # define INT_LEAST16_MAX INT16_MAX
  605. # define INT_LEAST32_MAX INT32_MAX
  606. # define INT_LEAST64_MAX INT64_MAX
  607. /* Maximum of unsigned integral types having a minimum size. */
  608. # define UINT_LEAST8_MAX UINT8_MAX
  609. # define UINT_LEAST16_MAX UINT16_MAX
  610. # define UINT_LEAST32_MAX UINT32_MAX
  611. # define UINT_LEAST64_MAX UINT64_MAX
  612. /* shortcircuit*/
  613. #endif
  614. /* once */
  615. #endif
  616. #endif
  617. STDINT_EOF
  618. fi
  619. if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
  620. AC_MSG_NOTICE([$ac_stdint_h is unchanged])
  621. else
  622. ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
  623. AS_MKDIR_P(["$ac_dir"])
  624. rm -f $ac_stdint_h
  625. mv $ac_stdint $ac_stdint_h
  626. fi
  627. ],[# variables for create stdint.h replacement
  628. PACKAGE="$PACKAGE"
  629. VERSION="$VERSION"
  630. ac_stdint_h="$ac_stdint_h"
  631. _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
  632. ac_cv_stdint_message="$ac_cv_stdint_message"
  633. ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
  634. ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
  635. ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
  636. ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
  637. ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
  638. ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
  639. ac_cv_char_data_model="$ac_cv_char_data_model"
  640. ac_cv_long_data_model="$ac_cv_long_data_model"
  641. ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
  642. ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
  643. ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
  644. ])
  645. ])