📄 stdint.m4
字号:
dnl AC_NEED_STDINT_H ( HEADER-TO-GENERATE )dnl Copyright 2001-2002 by Dan Fandrich <dan@coneharvesters.com>dnl This file may be copied and used freely without restrictions. No warrantydnl is expressed or implied.dnldnl Look for a header file that defines size-specific integer types like thednl ones recommended to be in stdint.h in the C99 standard (e.g. uint32_t).dnl This is a dumbed-down version of the macro of the same name in the filednl ac_need_stdint_h.m4 which is part of the ac-archive, available atdnl <URL:http://ac-archive.sourceforge.net/> (also, another macrodnl AC_CREATE_STDINT_H by the same author). This version is not as smart,dnl but works on older autoconf versions and has a different license.dnl AX_CHECK_DEFINED_TYPE ( TYPE, FILE, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND )dnl This is similar to _AC_CHECK_TYPE_NEW (a.k.a. new syntax version ofdnl AC_CHECK_TYPE) in autoconf 2.50 but works on older versionsAC_DEFUN([AX_CHECK_DEFINED_TYPE],[AC_MSG_CHECKING([for $1 in $2])AC_EGREP_CPP(changequote(<<,>>)dnl<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnlchangequote([,]), [#include <$2>],ac_cv_type_$1=yes, ac_cv_type_$1=no)dnlAC_MSG_RESULT($ac_cv_type_$1)if test $ac_cv_type_$1 = yes; then $3else $4fi])dnl Look for a header file that defines size-specific integer typesAC_DEFUN([AX_NEED_STDINT_H],[changequote(, )dnlac_dir=`echo "$1"|sed 's%/[^/][^/]*$%%'`changequote([, ])dnlif test "$ac_dir" != "$1" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir"fiAX_CHECK_DEFINED_TYPE(uint8_t,stdint.h,[cat > "$1" <<EOF/* This file is generated automatically by configure */#include <stdint.h>EOF],[AX_CHECK_DEFINED_TYPE(uint8_t,inttypes.h,[cat > "$1" <<EOF/* This file is generated automatically by configure */#include <inttypes.h>EOF],[AX_CHECK_DEFINED_TYPE(uint8_t,sys/types.h,[cat > "$1" <<EOF/* This file is generated automatically by configure */#include <sys/types.h>EOF],[AX_CHECK_DEFINED_TYPE(u_int8_t,sys/types.h,[cat > "$1" <<EOF/* This file is generated automatically by configure */#ifndef __STDINT_H#define __STDINT_H#include <sys/types.h>typedef u_int8_t uint8_t;typedef u_int16_t uint16_t;typedef u_int32_t uint32_t;EOFAX_CHECK_DEFINED_TYPE(u_int64_t,sys/types.h,[cat >> "$1" <<EOFtypedef u_int64_t uint64_t;#endif /*!__STDINT_H*/EOF],[cat >> "$1" <<EOF/* 64-bit types are not available on this system *//* typedef u_int64_t uint64_t; */#endif /*!__STDINT_H*/EOF])],[AC_MSG_WARN([I can't find size-specific integer definitions on this system])if test -e "$1" ; then rm -f "$1"fi])])])])dnl])AC_DEFUN([AX_CHECK_DATA_MODEL],[ AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void*) ac_cv_char_data_model="" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" AC_MSG_CHECKING([data model]) case "$ac_cv_char_data_model/$ac_cv_long_data_model" in 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; 222/*|333/*|444/*|666/*|888/*) : ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; *) ac_cv_data_model="none" ; n="very unusual model" ;; esac AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])])dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do unset ac_cv_type_uintptr_t unset ac_cv_type_uint64_t AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$1],[$1]) break done AC_MSG_CHECKING([for stdint uintptr_t]) ])])AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$1],[$1]) break break; done AC_MSG_CHECKING([for stdint uint32_t]) ])])AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>]) AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$1],[$1]) break break; done AC_MSG_CHECKING([for stdint u_int32_t]) ])])AC_DEFUN([AX_CREATE_STDINT_H],[# ------ AX CREATE STDINT H -------------------------------------AC_MSG_CHECKING([for stdint types])ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`# try to shortcircuit - if the default include path of the compiler# can find a "stdint.h" header then we assume that all compilers can.AC_CACHE_VAL([ac_cv_header_stdint_t],[old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""old_CFLAGS="$CFLAGS" ; CFLAGS=""AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],[ac_cv_stdint_result="(assuming C99 compatible system)" ac_cv_header_stdint_t="stdint.h"; ],[ac_cv_header_stdint_t=""])CXXFLAGS="$old_CXXFLAGS"CPPFLAGS="$old_CPPFLAGS"CFLAGS="$old_CFLAGS" ])v="... $ac_cv_header_stdint_h"if test "$ac_stdint_h" = "stdint.h" ; then AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])elif test "$ac_stdint_h" = "inttypes.h" ; then AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])elif test "_$ac_cv_header_stdint_t" = "_" ; then AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])else ac_cv_header_stdint="$ac_cv_header_stdint_t" AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])fiif test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..dnl .....intro message done, now do a few system checks.....dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type,dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEWdnl instead that is triggered with 3 or more arguments (see types.m4)inttype_headers=`echo $2 | sed -e 's/,/ /g'`ac_cv_stdint_result="(no helpful system typedefs seen)"AX_CHECK_HEADER_STDINT_X(dnl stdint.h inttypes.h sys/inttypes.h $inttype_headers, ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")if test "_$ac_cv_header_stdint_x" = "_" ; thenAX_CHECK_HEADER_STDINT_O(dnl, inttypes.h sys/inttypes.h stdint.h $inttype_headers, ac_cv_stdint_result="(seen uint32_t$and64 in $i)")fiif test "_$ac_cv_header_stdint_x" = "_" ; thenif test "_$ac_cv_header_stdint_o" = "_" ; thenAX_CHECK_HEADER_STDINT_U(dnl, sys/types.h inttypes.h sys/inttypes.h $inttype_headers, ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")fi fidnl if there was no good C99 header file, do some typedef checks...if test "_$ac_cv_header_stdint_x" = "_" ; then AC_MSG_CHECKING([for stdint datatype model]) AC_MSG_RESULT([(..)]) AX_CHECK_DATA_MODELfiif test "_$ac_cv_header_stdint_x" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_x"elif test "_$ac_cv_header_stdint_o" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_o"elif test "_$ac_cv_header_stdint_u" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_u"else ac_cv_header_stdint="stddef.h"fiAC_MSG_CHECKING([for extra inttypes in chosen header])AC_MSG_RESULT([($ac_cv_header_stdint)])dnl see if int_least and int_fast types are present in _this_ header.unset ac_cv_type_int_least32_tunset ac_cv_type_int_fast32_tAC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])fi # shortcircut to system "stdint.h"# ------------------ PREPARE VARIABLES ------------------------------if test "$GCC" = "yes" ; thenac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`elseac_cv_stdint_message="using $CC"fiAC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl$ac_cv_stdint_result])dnl -----------------------------------------------------------------# ----------------- DONE inttypes.h checks START header -------------AC_CONFIG_COMMANDS([$ac_stdint_h],[AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)ac_stdint=$tmp/_stdint.hecho "#ifndef" $_ac_stdint_h >$ac_stdintecho "#define" $_ac_stdint_h "1" >>$ac_stdintecho "#ifndef" _GENERATED_STDINT_H >>$ac_stdintecho "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdintecho "/* generated $ac_cv_stdint_message */" >>$ac_stdintif test "_$ac_cv_header_stdint_t" != "_" ; thenecho "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdintecho "#include <stdint.h>" >>$ac_stdintecho "#endif" >>$ac_stdintecho "#endif" >>$ac_stdintelsecat >>$ac_stdint <<STDINT_EOF/* ................... shortcircuit part ........................... */#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H#include <stdint.h>#else#include <stddef.h>/* .................... configured part ............................ */STDINT_EOFecho "/* whether we have a C99 compatible stdint header file */" >>$ac_stdintif test "_$ac_cv_header_stdint_x" != "_" ; then ac_header="$ac_cv_header_stdint_x" echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdintelse echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdintfiecho "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdintif test "_$ac_cv_header_stdint_o" != "_" ; then ac_header="$ac_cv_header_stdint_o" echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdintelse echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdintfiecho "/* whether we have a BSD compatible inet types header */" >>$ac_stdintif test "_$ac_cv_header_stdint_u" != "_" ; then ac_header="$ac_cv_header_stdint_u" echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdintelse echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdintfiecho "" >>$ac_stdintif test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then echo "#include <$ac_header>" >>$ac_stdint echo "" >>$ac_stdintfi fiecho "/* which 64bit typedef has been found */" >>$ac_stdintif test "$ac_cv_type_uint64_t" = "yes" ; thenecho "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdintelseecho "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdintfiif test "$ac_cv_type_u_int64_t" = "yes" ; thenecho "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdintelseecho "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdintfiecho "" >>$ac_stdintecho "/* which type model has been detected */" >>$ac_stdintif test "_$ac_cv_char_data_model" != "_" ; thenecho "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdintecho "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdintelseecho "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdintecho "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdintfiecho "" >>$ac_stdintecho "/* whether int_least types were detected */" >>$ac_stdintif test "$ac_cv_type_int_least32_t" = "yes"; thenecho "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdintelseecho "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdintfiecho "/* whether int_fast types were detected */" >>$ac_stdintif test "$ac_cv_type_int_fast32_t" = "yes"; thenecho "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdintelseecho "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdintfi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -