From 7691fc4f9e797444e3509ecde404847aad26be80 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 13 Apr 2020 21:04:45 +0200 Subject: [PATCH] configure: check for u_int and friends --- acsite.m4 | 45 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 4 ++++ src/suricata-common.h | 13 +++++++++++++ 3 files changed, 62 insertions(+) diff --git a/acsite.m4 b/acsite.m4 index 3d82c223339d..78b4f15f1473 100644 --- a/acsite.m4 +++ b/acsite.m4 @@ -9,6 +9,51 @@ AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)]) AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)]) AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)]) +AC_DEFUN([AC_TYPE_UINT], [_AC_TYPE_UTYPE(u_int)]) +AC_DEFUN([AC_TYPE_ULONG], [_AC_TYPE_UTYPE(u_long)]) +AC_DEFUN([AC_TYPE_UCHAR], [_AC_TYPE_UTYPE(u_char)]) +AC_DEFUN([AC_TYPE_USHORT], [_AC_TYPE_UTYPE(u_short)]) + +# _AC_TYPE_UTYPE(BASE) +# ------------------- +AC_DEFUN([_AC_TYPE_UTYPE], +[ + AC_CACHE_CHECK([for $1], [ac_cv_c_$1], + [ac_cv_c_$1=no + case $1 in + "u_long") + ac_cv_c_$1_type="U_LONG" + ;; + "u_int") + ac_cv_c_$1_type="U_INT" + ;; + "u_short") + ac_cv_c_$1_type="U_SHORT" + ;; + "u_char") + ac_cv_c_$1_type="U_CHAR" + ;; + *) + ;; + esac + + AC_COMPILE_IFELSE( + [AC_LANG_BOOL_COMPILE_TRY( + [AC_INCLUDES_DEFAULT], + [[($1) -1 >> ((sizeof($1) * 8) - 1) == 1]])], + [AS_CASE([$1], [$1], + [ac_cv_c_$1=yes], + [ac_cv_c_$1=no])]) + ]) + case $ac_cv_c_$1 in #( + no) + AC_DEFINE_UNQUOTED([HAVE_TYPE_$ac_cv_c_$1_type_NOT_DEFINED], [1], [$1 is undefined]) + ;; + *) + ;; + esac +])# _AC_TYPE_UTYPE + # _AC_TYPE_INT(NBITS) # ------------------- AC_DEFUN([_AC_TYPE_INT], diff --git a/configure.ac b/configure.ac index c65500e6221e..82d6d353df26 100644 --- a/configure.ac +++ b/configure.ac @@ -223,6 +223,10 @@ AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T + AC_TYPE_UINT + AC_TYPE_USHORT + AC_TYPE_ULONG + AC_TYPE_UCHAR AC_STRUCT_TIMEZONE AC_CHECK_TYPES([ptrdiff_t]) AC_HEADER_STDBOOL diff --git a/src/suricata-common.h b/src/suricata-common.h index 4cc3201e0067..7c2a1d920fb2 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -125,6 +125,19 @@ #include /* for sched_setaffinity(2) */ #endif +#ifdef HAVE_TYPE_U_LONG_NOT_DEFINED +typedef unsigned long int u_long +#endif +#ifdef HAVE_TYPE_U_INT_NOT_DEFINED +typedef unsigned int u_int +#endif +#ifdef HAVE_TYPE_U_SHORT_NOT_DEFINED +typedef unsigned short u_short +#endif +#ifdef HAVE_TYPE_U_CHAR_NOT_DEFINED +typedef unsigned char u_char +#endif + #include #ifdef HAVE_SYSLOG_H