summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-08-13 03:40:06 +0200
committerHaru <haru@dotalux.com>2015-08-13 04:15:58 +0200
commit1b4d33767fde9c55aa2e32f1a313688dc48a6ad4 (patch)
tree60d6a99177d72584e03c24f47af5f29a02fed623
parent08e100ec056ef7f8dabbbe33d3de14410c25f367 (diff)
downloadhercules-1b4d33767fde9c55aa2e32f1a313688dc48a6ad4.tar.gz
hercules-1b4d33767fde9c55aa2e32f1a313688dc48a6ad4.tar.bz2
hercules-1b4d33767fde9c55aa2e32f1a313688dc48a6ad4.tar.xz
hercules-1b4d33767fde9c55aa2e32f1a313688dc48a6ad4.zip
Added check for execinfo.h/backtrace() to the configure script
- This fixes compilation on systems such as FreeBSD, where -lexecinfo is necessary, or Cygwin, where execinfo.h is not available. Signed-off-by: Haru <haru@dotalux.com>
-rwxr-xr-xconfigure74
-rw-r--r--configure.in15
-rw-r--r--src/common/nullpo.c12
3 files changed, 94 insertions, 7 deletions
diff --git a/configure b/configure
index b022ca2d5..2500494c9 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in 3bd5d73.
+# From configure.in 08e100e.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
@@ -7988,6 +7988,78 @@ else
fi
+# execinfo (backtrace)
+for ac_header in execinfo.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default"
+if test "x$ac_cv_header_execinfo_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_EXECINFO_H 1
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing backtrace" >&5
+$as_echo_n "checking for library containing backtrace... " >&6; }
+if ${ac_cv_search_backtrace+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char backtrace ();
+int
+main ()
+{
+return backtrace ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' execinfo; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_backtrace=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_backtrace+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_backtrace+:} false; then :
+
+else
+ ac_cv_search_backtrace=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_backtrace" >&5
+$as_echo "$ac_cv_search_backtrace" >&6; }
+ac_res=$ac_cv_search_backtrace
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+ CFLAGS="$CFLAGS -DHAVE_EXECINFO"
+
+fi
+
+
+fi
+
+done
+
#
# MySQL library
diff --git a/configure.in b/configure.in
index d17f5b4a7..8567c6bcb 100644
--- a/configure.in
+++ b/configure.in
@@ -1268,6 +1268,21 @@ AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread lib
AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+# execinfo (backtrace)
+AC_CHECK_HEADERS([execinfo.h],
+ [
+ AC_SEARCH_LIBS([backtrace],
+ [execinfo],
+ [
+ CFLAGS="$CFLAGS -DHAVE_EXECINFO"
+ ],
+ [
+ ]
+ )
+ ],
+ [
+ ]
+)
#
# MySQL library
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index 395002b64..0db714ae1 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -12,9 +12,9 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#if defined(__GNUC__) && !defined(CYGWIN)
+#ifdef HAVE_EXECINFO
#include <execinfo.h>
-#endif
+#endif // HAVE_EXECINFO
struct nullpo_interface nullpo_s;
@@ -28,12 +28,12 @@ struct nullpo_interface nullpo_s;
* @param title Message title to display (i.e. failed assertion or nullpo info)
*/
void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
-#if defined(__GNUC__) && !defined(CYGWIN)
+#ifdef HAVE_EXECINFO
void *array[10];
int size;
char **strings;
int i;
-#endif
+#endif // HAVE_EXECINFO
if (file == NULL)
file = "??";
@@ -42,13 +42,13 @@ void assert_report(const char *file, int line, const char *func, const char *tar
ShowError("--- %s --------------------------------------------\n", title);
ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func);
-#if defined(__GNUC__) && !defined(CYGWIN)
+#ifdef HAVE_EXECINFO
size = (int)backtrace(array, 10);
strings = backtrace_symbols(array, size);
for (i = 0; i < size; i++)
ShowError("%s\n", strings[i]);
free(strings);
-#endif
+#endif // HAVE_EXECINFO
ShowError("--- end %s ----------------------------------------\n", title);
}