From 73b5cc9a2676cc7ed671daef333d433dff055805 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 3 Mar 2016 15:59:25 +0000 Subject: [PATCH] - configure tests for the weak attribute support by the compiler. git-svn-id: file:///svn/unbound/trunk@3645 be551aaa-1e26-0410-a405-d3ace91eadb9 --- compat/explicit_bzero.c | 4 ++++ config.h.in | 3 +++ configure | 42 +++++++++++++++++++++++++++++++++++++++++ configure.ac | 23 ++++++++++++++++++++++ doc/Changelog | 3 +++ 5 files changed, 75 insertions(+) diff --git a/compat/explicit_bzero.c b/compat/explicit_bzero.c index a3ba2798a..5f1c427c2 100644 --- a/compat/explicit_bzero.c +++ b/compat/explicit_bzero.c @@ -6,7 +6,11 @@ #include "config.h" #include +#ifdef HAVE_ATTR_WEAK __attribute__((weak)) void +#else +void +#endif __explicit_bzero_hook(void *ATTR_UNUSED(buf), size_t ATTR_UNUSED(len)) { } diff --git a/config.h.in b/config.h.in index 59277ddf0..c29898862 100644 --- a/config.h.in +++ b/config.h.in @@ -42,6 +42,9 @@ /* Whether the C compiler accepts the "unused" attribute */ #undef HAVE_ATTR_UNUSED +/* Whether the C compiler accepts the "weak" attribute */ +#undef HAVE_ATTR_WEAK + /* Define to 1 if you have the `chown' function. */ #undef HAVE_CHOWN diff --git a/configure b/configure index 69ebea331..24f7fd583 100755 --- a/configure +++ b/configure @@ -6118,6 +6118,48 @@ $as_echo "#define HAVE_ATTR_UNUSED 1" >>confdefs.h fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"weak\" attribute" >&5 +$as_echo_n "checking whether the C compiler (${CC-cc}) accepts the \"weak\" attribute... " >&6; } +if ${ac_cv_c_weak_attribute+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_weak_attribute=no +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #include +__attribute__((weak)) void f(int x) { printf("%d", x); } + +int +main () +{ + + f(1); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_weak_attribute="yes" +else + ac_cv_c_weak_attribute="no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_weak_attribute" >&5 +$as_echo "$ac_cv_c_weak_attribute" >&6; } +if test $ac_cv_c_weak_attribute = yes; then + +$as_echo "#define HAVE_ATTR_WEAK 1" >>confdefs.h + +fi + + if test "$srcdir" != "."; then CPPFLAGS="$CPPFLAGS -I$srcdir" fi diff --git a/configure.ac b/configure.ac index 089ec62a3..4d9d218f3 100644 --- a/configure.ac +++ b/configure.ac @@ -258,6 +258,29 @@ AC_C_INLINE ACX_CHECK_FORMAT_ATTRIBUTE ACX_CHECK_UNUSED_ATTRIBUTE +AC_DEFUN([CHECK_WEAK_ATTRIBUTE], +[AC_REQUIRE([AC_PROG_CC]) +AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute) +AC_CACHE_VAL(ac_cv_c_weak_attribute, +[ac_cv_c_weak_attribute=no +AC_TRY_COMPILE( +[ #include +__attribute__((weak)) void f(int x) { printf("%d", x); } +], [ + f(1); +], +[ac_cv_c_weak_attribute="yes"], +[ac_cv_c_weak_attribute="no"]) +]) + +AC_MSG_RESULT($ac_cv_c_weak_attribute) +if test $ac_cv_c_weak_attribute = yes; then + AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute]) +fi +])dnl End of CHECK_WEAK_ATTRIBUTE + +CHECK_WEAK_ATTRIBUTE + if test "$srcdir" != "."; then CPPFLAGS="$CPPFLAGS -I$srcdir" fi diff --git a/doc/Changelog b/doc/Changelog index 9184d1411..24ec0467d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +03 March 2016: Wouter + - configure tests for the weak attribute support by the compiler. + 02 March 2016: Wouter - 1.5.8 release tag - trunk contains 1.5.9 in development.