Include alloca.h if we have it.

Bug: 14552
Change-Id: I799691f7f33ca56748ed4e51d7d548f37769837b
Reviewed-on: https://code.wireshark.org/review/26611
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-03-23 14:21:06 -07:00
parent a7edc4f25f
commit d12a41b17a
4 changed files with 38 additions and 3 deletions

View File

@ -89,11 +89,25 @@ cmake_pop_check_state()
check_function_exists("getopt_long" HAVE_GETOPT_LONG)
if(HAVE_GETOPT_LONG)
#
# The OS has getopt_long(), so it might have optreset.
# Do we have it?
#
if(HAVE_GETOPT_H)
check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
else()
check_symbol_exists("optreset" HAVE_OPTRESET)
endif()
else()
#
# The OS doesn't have getopt_long(), so we're using the GNU libc
# version that we have in wsutil. It doesn't have optreset, so we
# don't need to check for it.
#
# However, it uses alloca(), so we may need to include alloca.h;
# check for it.
#
check_include_file("alloca.h" HAVE_ALLOCA_H)
endif()
check_function_exists("getifaddrs" HAVE_GETIFADDRS)
check_function_exists("issetugid" HAVE_ISSETUGID)

View File

@ -41,6 +41,9 @@
/* Enable AirPcap */
#cmakedefine HAVE_AIRPCAP 1
/* Define to 1 if you have the <alloca.h> header file. */
#cmakedefine HAVE_ALLOCA_H 1
/* Define to 1 if you have the <arpa/inet.h> header file. */
#cmakedefine HAVE_ARPA_INET_H 1

View File

@ -2309,16 +2309,26 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
#endif])
AC_REPLACE_FUNCS(getopt_long)
dnl
dnl Do we have optreset?
dnl
if test "x$ac_cv_func_getopt_long" = xyes; then
#
# The OS has getopt_long(), so it might have optreset. Do we have it?
#
AC_CACHE_CHECK([whether optreset is defined], ac_cv_have_optreset,
AC_LINK_IFELSE([AC_LANG_SOURCE([[extern int optreset;return optreset;]])],
ac_cv_have_optreset=yes, ac_cv_have_optreset=no))
if test "$ac_cv_have_optreset" = yes ; then
AC_DEFINE(HAVE_OPTRESET, 1, [Define to 1 if you have the optreset variable])
fi
else
#
# The OS doesn't have getopt_long(), so we're using the GNU libc
# version that we have in wsutil. It doesn't have optreset, so we
# don't need to check for it.
#
# However, it uses alloca(), so we may need to include alloca.h;
# check for it.
#
AC_CHECK_HEADERS(alloca.h)
fi
AC_REPLACE_FUNCS(strptime)

View File

@ -64,6 +64,14 @@
# define _(msgid) (msgid)
#endif
/*
* If we have alloca.h, we assume we need it.
*/
#
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef _WIN32
# define alloca _alloca
#endif