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