aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-03-23 14:21:06 -0700
committerGuy Harris <guy@alum.mit.edu>2018-03-23 22:39:07 +0000
commitd12a41b17a006ccc1b0f98e9df3fc442e4ee7643 (patch)
tree009988dd542bad8784861bce8bb0df0483ba122a
parenta7edc4f25f1cffb452959e2093fe7b2a65e75d79 (diff)
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>
-rw-r--r--ConfigureChecks.cmake14
-rw-r--r--cmakeconfig.h.in3
-rw-r--r--configure.ac16
-rw-r--r--wsutil/getopt_long.c8
4 files changed, 38 insertions, 3 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index bd6e977348..9079ee396f 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -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)
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index e5f12e3f49..566bfc9d34 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -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
diff --git a/configure.ac b/configure.ac
index 8d743f3b2f..b5ee1f0626 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/wsutil/getopt_long.c b/wsutil/getopt_long.c
index 3b19fe6c32..3e2a9bce5e 100644
--- a/wsutil/getopt_long.c
+++ b/wsutil/getopt_long.c
@@ -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