From: Guy Harris Date: Wed, 23 Apr 2014 17:56:20 +0000 (-0700) Subject: We still need u_intN_t. X-Git-Tag: tcpdump-4.6.0~64 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/30f0d2314d1086ebf4bad29b1d11c7916338b95d We still need u_intN_t. Some libpcap headers use them, and even if we change libpcap to use uintN_t, we don't require that tcpdump 4.x go with libpcap 1.x - we allow people to install the latest tcpdump even if they have an older libpcap and don't want to install a newer one. However, we now define them in terms of the C99 uintN_t types, rather than trying to guess what's appropriate; using unsigned long long for u_int64_t meant that, on some platforms, u_int64_t didn't match PRI[doux]64, and using unsigned long obviously won't work on ILP32 platforms. Also, we already had calls to the autoconf macros for C99 types; get rid of the ones we added. Also also, clean up a comment in tcpdump-stdinc.h. --- diff --git a/config.h.in b/config.h.in index c8c6507c..4cdb31b7 100644 --- a/config.h.in +++ b/config.h.in @@ -334,6 +334,18 @@ a type exists and the standard includes do not define it. */ #undef int8_t +/* Define to `uint16_t' if u_int16_t not defined. */ +#undef u_int16_t + +/* Define to `uint32_t' if u_int32_t not defined. */ +#undef u_int32_t + +/* Define to `uint64_t' if u_int64_t not defined. */ +#undef u_int64_t + +/* Define to `uint8_t' if u_int8_t not defined. */ +#undef u_int8_t + /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t diff --git a/configure b/configure index 37aa8a1b..21ce37b8 100755 --- a/configure +++ b/configure @@ -6797,6 +6797,7 @@ fi # # Make sure we have definitions for all the C99 specified-width types # (regardless of whether the environment is a C99 environment or not). +# ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" case $ac_cv_c_int8_t in #( no|yes) ;; #( @@ -6897,107 +6898,56 @@ _ACEOF # -# The minimum version of autoconf that we support is 2.61, and it -# supports the AC_TYPE_UINTn_T macros. Use them; we've stopped -# using the old BSD-style u_intXX_t types. +# Define the old BSD specified-width types in terms of the C99 types; +# we may need them with libpcap include files. # -ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" -case $ac_cv_c_uint8_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT8_T 1" >>confdefs.h - +ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default +#include -cat >>confdefs.h <<_ACEOF -#define uint8_t $ac_cv_c_uint8_t -_ACEOF -;; - esac +" +if test "x$ac_cv_type_u_int8_t" = xyes; then : -ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" -case $ac_cv_c_int8_t in #( - no|yes) ;; #( - *) +else -cat >>confdefs.h <<_ACEOF -#define int8_t $ac_cv_c_int8_t -_ACEOF -;; -esac +$as_echo "#define u_int8_t uint8_t" >>confdefs.h -ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" -case $ac_cv_c_uint16_t in #( - no|yes) ;; #( - *) +fi +ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default +#include -cat >>confdefs.h <<_ACEOF -#define uint16_t $ac_cv_c_uint16_t -_ACEOF -;; - esac +" +if test "x$ac_cv_type_u_int16_t" = xyes; then : -ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" -case $ac_cv_c_int16_t in #( - no|yes) ;; #( - *) +else -cat >>confdefs.h <<_ACEOF -#define int16_t $ac_cv_c_int16_t -_ACEOF -;; -esac +$as_echo "#define u_int16_t uint16_t" >>confdefs.h -ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" -case $ac_cv_c_uint32_t in #( - no|yes) ;; #( - *) - -$as_echo "#define _UINT32_T 1" >>confdefs.h +fi +ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default +#include -cat >>confdefs.h <<_ACEOF -#define uint32_t $ac_cv_c_uint32_t -_ACEOF -;; - esac +" +if test "x$ac_cv_type_u_int32_t" = xyes; then : -ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" -case $ac_cv_c_int32_t in #( - no|yes) ;; #( - *) +else -cat >>confdefs.h <<_ACEOF -#define int32_t $ac_cv_c_int32_t -_ACEOF -;; -esac +$as_echo "#define u_int32_t uint32_t" >>confdefs.h -ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" -case $ac_cv_c_uint64_t in #( - no|yes) ;; #( - *) +fi -$as_echo "#define _UINT64_T 1" >>confdefs.h +ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default +#include +" +if test "x$ac_cv_type_u_int64_t" = xyes; then : -cat >>confdefs.h <<_ACEOF -#define uint64_t $ac_cv_c_uint64_t -_ACEOF -;; - esac +else -ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" -case $ac_cv_c_int64_t in #( - no|yes) ;; #( - *) +$as_echo "#define u_int64_t uint64_t" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define int64_t $ac_cv_c_int64_t -_ACEOF -;; -esac +fi # diff --git a/configure.in b/configure.in index a027c5c6..dde10b38 100644 --- a/configure.in +++ b/configure.in @@ -869,6 +869,7 @@ fi # # Make sure we have definitions for all the C99 specified-width types # (regardless of whether the environment is a C99 environment or not). +# AC_TYPE_INT8_T AC_TYPE_INT16_T AC_TYPE_INT32_T @@ -879,18 +880,33 @@ AC_TYPE_UINT32_T AC_TYPE_UINT64_T # -# The minimum version of autoconf that we support is 2.61, and it -# supports the AC_TYPE_UINTn_T macros. Use them; we've stopped -# using the old BSD-style u_intXX_t types. +# Define the old BSD specified-width types in terms of the C99 types; +# we may need them with libpcap include files. # -AC_TYPE_UINT8_T -AC_TYPE_INT8_T -AC_TYPE_UINT16_T -AC_TYPE_INT16_T -AC_TYPE_UINT32_T -AC_TYPE_INT32_T -AC_TYPE_UINT64_T -AC_TYPE_INT64_T +AC_CHECK_TYPE([u_int8_t], , + [AC_DEFINE([u_int8_t], [uint8_t], + [Define to `uint8_t' if u_int8_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int16_t], , + [AC_DEFINE([u_int16_t], [uint16_t], + [Define to `uint16_t' if u_int16_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int32_t], , + [AC_DEFINE([u_int32_t], [uint32_t], + [Define to `uint32_t' if u_int32_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int64_t], , + [AC_DEFINE([u_int64_t], [uint64_t], + [Define to `uint64_t' if u_int64_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) # # Check for diff --git a/tcpdump-stdinc.h b/tcpdump-stdinc.h index cf763cff..9a068e64 100644 --- a/tcpdump-stdinc.h +++ b/tcpdump-stdinc.h @@ -31,8 +31,8 @@ /* * Include the appropriate OS header files on Windows and various flavors - * of UNIX, and also define some additional items and include various - * non-OS header files on Windows, and; this isolates most of the platform + * of UNIX, include various non-OS header files on Windows, and define + * various items as needed, to isolate most of tcpdump's platform * differences to this one file. */