]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- configure tests for the weak attribute support by the compiler.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Mar 2016 15:59:25 +0000 (15:59 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Mar 2016 15:59:25 +0000 (15:59 +0000)
git-svn-id: file:///svn/unbound/trunk@3645 be551aaa-1e26-0410-a405-d3ace91eadb9

compat/explicit_bzero.c
config.h.in
configure
configure.ac
doc/Changelog

index a3ba2798a23b892ef5165226386f4c5ae6ce3c24..5f1c427c2137916aa7254055643420678a3f2bee 100644 (file)
@@ -6,7 +6,11 @@
 #include "config.h"
 #include <string.h>
 
+#ifdef HAVE_ATTR_WEAK
 __attribute__((weak)) void
+#else
+void
+#endif
 __explicit_bzero_hook(void *ATTR_UNUSED(buf), size_t ATTR_UNUSED(len))
 {
 }
index 59277ddf0a73f2c298a640a70e95dee9743e6ec3..c298988628b05b83c1a90a0a0b39f064e61c6c15 100644 (file)
@@ -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
 
index 69ebea331a707676551cb512ce99d17941147c81..24f7fd583728e8fcf6eda3cc32ad0e76b2537c5c 100755 (executable)
--- 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 <stdio.h>
+__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
index 089ec62a35662c5e39e2a2087fef63514ab2e04c..4d9d218f3c016597fc086d2847a85ddc9097a332 100644 (file)
@@ -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 <stdio.h>
+__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
index 9184d1411638b6929bfa0b44023ce6782c0b7930..24ec0467d8bf2b664988a6dae04f84110af04444 100644 (file)
@@ -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.