]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix to detect if atomic_store links in configure.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Apr 2025 09:06:25 +0000 (11:06 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Apr 2025 09:06:25 +0000 (11:06 +0200)
config.h.in
configure
configure.ac
daemon/remote.c
doc/Changelog

index 246f06c2ffd1fbd0f6aa3e0578e3a6ea41768f01..f2dc8c8b92b33c0f4888b9a3cc987ddd5065d94c 100644 (file)
 /* Define if we have LibreSSL */
 #undef HAVE_LIBRESSL
 
+/* If we have atomic_store */
+#undef HAVE_LINK_ATOMIC_STORE
+
 /* Define to 1 if you have the <linux/net_tstamp.h> header file. */
 #undef HAVE_LINUX_NET_TSTAMP_H
 
index 2225dba1f2c0355b8de4f4109206449a4318851d..0b78d97b16e97a05f83e41f6d7e90c4aac77f78e 100755 (executable)
--- a/configure
+++ b/configure
@@ -23530,6 +23530,48 @@ if echo $host_os | grep darwin8 > /dev/null; then
 printf "%s\n" "#define DARWIN_BROKEN_SETREUID 1" >>confdefs.h
 
 fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for atomic_store" >&5
+printf %s "checking for atomic_store... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+#ifdef HAVE_STDATOMIC_H
+#include <stdatomic.h>
+#endif
+
+int
+main (void)
+{
+
+       int newvar = 5, var = 0;
+       atomic_store((_Atomic int*)&var, newvar);
+       newvar = 0;
+       /* condition to use the variables. */
+       if(var == newvar) return 1;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+
+printf "%s\n" "#define HAVE_LINK_ATOMIC_STORE 1" >>confdefs.h
+
+
+else $as_nop
+
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+
 ac_fn_check_decl "$LINENO" "inet_pton" "ac_cv_have_decl_inet_pton" "
 $ac_includes_default
 #ifdef HAVE_NETINET_IN_H
index 2383934f85485438eabcd2b47034cb66c7c2f070..76239c099572bdfebda54cc17125c7778d036a65 100644 (file)
@@ -1818,6 +1818,25 @@ AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
 if echo $host_os | grep darwin8 > /dev/null; then
        AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
 fi
+
+AC_MSG_CHECKING([for atomic_store])
+AC_LINK_IFELSE([AC_LANG_PROGRAM(AC_INCLUDES_DEFAULT [[
+#ifdef HAVE_STDATOMIC_H
+#include <stdatomic.h>
+#endif
+]], [[
+       int newvar = 5, var = 0;
+       atomic_store((_Atomic int*)&var, newvar);
+       newvar = 0;
+       /* condition to use the variables. */
+       if(var == newvar) return 1;
+]])], [
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_LINK_ATOMIC_STORE, 1, [If we have atomic_store])
+], [
+       AC_MSG_RESULT([no])
+])
+
 AC_CHECK_DECLS([inet_pton,inet_ntop], [], [], [
 AC_INCLUDES_DEFAULT
 #ifdef HAVE_NETINET_IN_H
index 72c6345139c80681072278d55501a6128cf27fa2..3cf795a69943ab4f88c452d9112e976c88d337ac 100644 (file)
@@ -5450,7 +5450,7 @@ auth_zones_swap(struct auth_zones* az, struct auth_zones* data)
         * the xfer elements can continue to be their callbacks. */
 }
 
-#ifdef ATOMIC_POINTER_LOCK_FREE
+#if defined(ATOMIC_POINTER_LOCK_FREE) && defined(HAVE_LINK_ATOMIC_STORE)
 /** Fast reload thread, if atomics are available, copy the config items
  * one by one with atomic store operations. */
 static void
@@ -5819,7 +5819,7 @@ fr_atomic_copy_cfg(struct config_file* oldcfg, struct config_file* cfg,
 #endif
        COPY_VAR_int(ede);
 }
-#endif /* ATOMIC_POINTER_LOCK_FREE */
+#endif /* ATOMIC_POINTER_LOCK_FREE && HAVE_LINK_ATOMIC_STORE */
 
 /** fast reload thread, adjust the cache sizes */
 static void
@@ -5997,7 +5997,7 @@ fr_reload_config(struct fast_reload_thread* fr, struct config_file* newcfg,
                lock_basic_lock(&env->anchors->lock);
        }
 
-#ifdef ATOMIC_POINTER_LOCK_FREE
+#if defined(ATOMIC_POINTER_LOCK_FREE) && defined(HAVE_LINK_ATOMIC_STORE)
        if(fr->fr_nopause) {
                fr_atomic_copy_cfg(ct->oldcfg, env->cfg, newcfg);
        } else {
@@ -6006,7 +6006,7 @@ fr_reload_config(struct fast_reload_thread* fr, struct config_file* newcfg,
                *ct->oldcfg = *env->cfg;
                /* Insert new config elements. */
                *env->cfg = *newcfg;
-#ifdef ATOMIC_POINTER_LOCK_FREE
+#if defined(ATOMIC_POINTER_LOCK_FREE) && defined(HAVE_LINK_ATOMIC_STORE)
        }
 #endif
 
@@ -6015,7 +6015,7 @@ fr_reload_config(struct fast_reload_thread* fr, struct config_file* newcfg,
                log_ident_set_or_default(env->cfg->log_identity);
        }
        /* the newcfg elements are in env->cfg, so should not be freed here. */
-#ifdef ATOMIC_POINTER_LOCK_FREE
+#if defined(ATOMIC_POINTER_LOCK_FREE) && defined(HAVE_LINK_ATOMIC_STORE)
        /* if used, the routine that copies the config has zeroed items. */
        if(!fr->fr_nopause)
 #endif
index 88ee61312936d07ce58466286c486083a44cca60..d37b0cd028173c432975b0f846fc050c5fcb31ed 100644 (file)
@@ -1,3 +1,6 @@
+9 April 2025: Wouter
+       - Fix to detect if atomic_store links in configure.
+
 8 April 2025: Wouter
        - Tag for 1.23.0rc1.
        - Fix fast_reload to print chroot with config file name.