]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove debugging implementation of stdatomic using mutexes
authorOndřej Surý <ondrej@isc.org>
Wed, 9 Mar 2022 09:42:44 +0000 (10:42 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 17 Mar 2022 20:44:04 +0000 (21:44 +0100)
Upcoming LLVM/Clang 15 has marked the ATOMIC_VAR_INIT() as deprecated
breaking the build.  In the previous commit, we have removed the use of
ATOMIC_VAR_INIT(), but as that was a prerequisite to using the
--enable-mutexatomic debugging mode, we have to remove the debugging
mode.

.gitlab-ci.yml
config.h.in
configure
configure.ac
lib/dns/rbtdb.c
lib/isc/include/isc/Makefile.in
lib/isc/include/isc/atomic.h
lib/isc/include/isc/mutexatomic.h [deleted file]
lib/ns/query.c

index 09aa3e998759eea443f0ec5a4aa18a5c4b68136f..96fda4c7056c5eb6e587239c34ad6ca35f438992 100644 (file)
@@ -1042,30 +1042,6 @@ unit:clang:tsan:
     - job: clang:tsan
       artifacts: true
 
-# Jobs for builds with mutex-based atomics on Debian 11 "bullseye" (amd64)
-
-gcc:mutexatomics:
-  variables:
-    CC: gcc
-    CFLAGS: "${CFLAGS_COMMON} -DISC_MEM_USE_INTERNAL_MALLOC=0"
-    EXTRA_CONFIGURE: "--with-libidn2 --enable-mutex-atomics"
-  <<: *base_image
-  <<: *build_job
-
-system:gcc:mutexatomics:
-  <<: *base_image
-  <<: *system_test_job
-  needs:
-    - job: gcc:mutexatomics
-      artifacts: true
-
-unit:gcc:mutexatomics:
-  <<: *base_image
-  <<: *unit_test_job
-  needs:
-    - job: gcc:mutexatomics
-      artifacts: true
-
 # Jobs for Clang builds on Debian 11 "bullseye" (amd64)
 
 clang:bullseye:amd64:
index 350cad433328b784f4e927abacb4ea4d5571cd9d..945e12318bce3d45170dd5e7ebb81a3918aab75c 100644 (file)
 /* Define to allow building of objects for dlopen(). */
 #undef ISC_DLZ_DLOPEN
 
-/* Define to emulate atomic variables with mutexes. */
-#undef ISC_MUTEX_ATOMICS
-
 /* define if the linker supports --wrap option */
 #undef LD_WRAP
 
index 58c482a077f74733258ef33c14305496abe5aa57..558f06393ee42254bc6465568d2d469f309e664d 100755 (executable)
--- a/configure
+++ b/configure
@@ -902,7 +902,6 @@ enable_warn_shadow
 enable_warn_error
 enable_developer
 enable_fuzzing
-enable_mutex_atomics
 with_python
 with_python_install_dir
 enable_kqueue
@@ -1620,8 +1619,6 @@ Optional Features:
   --enable-fuzzing=<afl|libfuzzer>
                           Enable fuzzing using American Fuzzy Lop or libFuzzer
                           (default=no)
-  --enable-mutex-atomics  emulate atomics by mutex-locked variables, useful
-                          for debugging [default=no]
   --enable-kqueue         use BSD kqueue when available [default=yes]
   --enable-epoll          use Linux epoll when available [default=auto]
   --enable-devpoll        use /dev/poll when available [default=yes]
@@ -12423,34 +12420,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 fi
 
-# [pairwise: --enable-mutex-atomics, --disable-mutex-atomics]
-# Check whether --enable-mutex_atomics was given.
-if test "${enable_mutex_atomics+set}" = set; then :
-  enableval=$enable_mutex_atomics;
-else
-  enable_mutex_atomics=no
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to emulate atomics with mutexes" >&5
-$as_echo_n "checking whether to emulate atomics with mutexes... " >&6; }
-case "$enable_mutex_atomics" in
-yes)
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define ISC_MUTEX_ATOMICS 1" >>confdefs.h
-
-        ;;
-no)
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-        ;;
-*)
-        as_fn_error $? "\"--enable-mutex-atomics requires yes or no\"" "$LINENO" 5
-        ;;
-esac
-
 #
 # Make very sure that these are the first files processed by
 # config.status, since we use the processed output as the input for
index b4165f00c75aace536c672bfc965dd7f4ae801f0..93e7d1769841e6501763542809f333f119bf9835 100644 (file)
@@ -145,28 +145,6 @@ AS_IF([test "$enable_fuzzing" = "afl"],
                         [AC_MSG_ERROR([set CC=afl-<gcc|clang> when --enable-fuzzing=afl is used])])
       ])
 
-# [pairwise: --enable-mutex-atomics, --disable-mutex-atomics]
-AC_ARG_ENABLE(mutex_atomics,
-             AS_HELP_STRING([--enable-mutex-atomics],
-                            [emulate atomics by mutex-locked variables, useful for debugging
-                               [default=no]]),
-             [],
-             [enable_mutex_atomics=no])
-
-AC_MSG_CHECKING([whether to emulate atomics with mutexes])
-case "$enable_mutex_atomics" in
-yes)
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(ISC_MUTEX_ATOMICS, 1, [Define to emulate atomic variables with mutexes.])
-        ;;
-no)
-        AC_MSG_RESULT(no)
-        ;;
-*)
-        AC_MSG_ERROR("--enable-mutex-atomics requires yes or no")
-        ;;
-esac
-
 #
 # Make very sure that these are the first files processed by
 # config.status, since we use the processed output as the input for
index f58e57d87df38703e5d309d35aa7f0bc4a2b1312..bd617b4e165c45cd5e6ae1b5038702b6ad56a7ae 100644 (file)
@@ -1465,11 +1465,9 @@ init_rdataset(dns_rbtdb_t *rbtdb, rdatasetheader_t *h) {
        atomic_init(&h->attributes, 0);
        atomic_init(&h->last_refresh_fail_ts, 0);
 
-#ifndef ISC_MUTEX_ATOMICS
        STATIC_ASSERT((sizeof(h->attributes) == 2),
                      "The .attributes field of rdatasetheader_t needs to be "
                      "16-bit int type exactly.");
-#endif /* !ISC_MUTEX_ATOMICS */
 
 #if TRACE_HEADER
        if (IS_CACHE(rbtdb) && rbtdb->common.rdclass == dns_rdataclass_in) {
@@ -7506,9 +7504,6 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, void *arg,
                header->is_mmapped = 1;
                header->node = rbtnode;
                header->node_is_relative = 0;
-#ifdef ISC_MUTEX_ATOMICS
-               atomic_init(&header->attributes, header->attributes.v);
-#endif
 
                if (RESIGN(header) &&
                    (header->resign != 0 || header->resign_lsb != 0)) {
index ed897f95bd0ee4cda8512d6f3a0a53136e7ba7ae..ea2af91e1bac8afe339cd4a1e97730e4ef7e9645 100644 (file)
@@ -29,7 +29,7 @@ HEADERS =     aes.h app.h assertions.h astack.h atomic.h backtrace.h \
                interfaceiter.h iterated_hash.h \
                lang.h lex.h lfsr.h lib.h likely.h list.h log.h \
                magic.h managers.h md.h mem.h meminfo.h \
-               mutexatomic.h mutexblock.h \
+               mutexblock.h \
                netaddr.h netmgr.h netscope.h nonce.h os.h parseint.h \
                pool.h portset.h print.h queue.h quota.h \
                radix.h random.h ratelimiter.h refcount.h regex.h \
index 1e05470be54f9f31b0faa836fb8a989a28092862..fd29202d9f1aa93e97b6a3f855579b3d3fbad6f7 100644 (file)
 
 #pragma once
 
-#ifdef ISC_MUTEX_ATOMICS
-#include <isc/mutexatomic.h>
-#else /* ifdef ISC_MUTEX_ATOMICS */
 #if HAVE_STDATOMIC_H
 #include <stdatomic.h>
 #else /* if HAVE_STDATOMIC_H */
 #include <isc/stdatomic.h>
 #endif /* if HAVE_STDATOMIC_H */
-#endif /* ifdef ISC_MUTEX_ATOMICS */
 
 /*
  * We define a few additional macros to make things easier
diff --git a/lib/isc/include/isc/mutexatomic.h b/lib/isc/include/isc/mutexatomic.h
deleted file mode 100644 (file)
index 796519d..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * SPDX-License-Identifier: MPL-2.0
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0.  If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#pragma once
-
-#include <inttypes.h>
-#include <stdbool.h>
-#if HAVE_UCHAR_H
-#include <uchar.h>
-#endif /* HAVE_UCHAR_H */
-
-#include <isc/mutex.h>
-#include <isc/util.h>
-
-#if !defined(__has_feature)
-#define __has_feature(x) 0
-#endif /* if !defined(__has_feature) */
-
-#if !defined(__has_extension)
-#define __has_extension(x) __has_feature(x)
-#endif /* if !defined(__has_extension) */
-
-#if !defined(__GNUC_PREREQ__)
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-#define __GNUC_PREREQ__(maj, min) \
-       ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else /* if defined(__GNUC__) && defined(__GNUC_MINOR__) */
-#define __GNUC_PREREQ__(maj, min) 0
-#endif /* if defined(__GNUC__) && defined(__GNUC_MINOR__) */
-#endif /* if !defined(__GNUC_PREREQ__) */
-
-#if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS)
-#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
-#define __CLANG_ATOMICS
-#elif __GNUC_PREREQ__(4, 7)
-#define __GNUC_ATOMICS
-#elif !defined(__GNUC__)
-#error "isc/stdatomic.h does not support your compiler"
-#endif /* if __has_extension(c_atomic) || __has_extension(cxx_atomic) */
-#endif /* if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) */
-
-#ifndef __ATOMIC_RELAXED
-#define __ATOMIC_RELAXED 0
-#endif /* ifndef __ATOMIC_RELAXED */
-#ifndef __ATOMIC_CONSUME
-#define __ATOMIC_CONSUME 1
-#endif /* ifndef __ATOMIC_CONSUME */
-#ifndef __ATOMIC_ACQUIRE
-#define __ATOMIC_ACQUIRE 2
-#endif /* ifndef __ATOMIC_ACQUIRE */
-#ifndef __ATOMIC_RELEASE
-#define __ATOMIC_RELEASE 3
-#endif /* ifndef __ATOMIC_RELEASE */
-#ifndef __ATOMIC_ACQ_REL
-#define __ATOMIC_ACQ_REL 4
-#endif /* ifndef __ATOMIC_ACQ_REL */
-#ifndef __ATOMIC_SEQ_CST
-#define __ATOMIC_SEQ_CST 5
-#endif /* ifndef __ATOMIC_SEQ_CST */
-
-enum memory_order {
-       memory_order_relaxed = __ATOMIC_RELAXED,
-       memory_order_consume = __ATOMIC_CONSUME,
-       memory_order_acquire = __ATOMIC_ACQUIRE,
-       memory_order_release = __ATOMIC_RELEASE,
-       memory_order_acq_rel = __ATOMIC_ACQ_REL,
-       memory_order_seq_cst = __ATOMIC_SEQ_CST
-};
-
-typedef enum memory_order memory_order;
-
-#define ___TYPEDEF(type, name, orig) \
-       typedef struct name {        \
-               isc_mutex_t m;       \
-               orig        v;       \
-       } type;
-
-#define _TYPEDEF_S(type) ___TYPEDEF(atomic_##type, atomic_##type##_s, type)
-#define _TYPEDEF_O(type, orig) \
-       ___TYPEDEF(atomic_##type, atomic_##type##_s, orig)
-#define _TYPEDEF_T(type) \
-       ___TYPEDEF(atomic_##type##_t, atomic_##type##_s, type##_t)
-
-#ifndef HAVE_UCHAR_H
-typedef uint_least16_t char16_t;
-typedef uint_least32_t char32_t;
-#endif /* HAVE_UCHAR_H */
-
-_TYPEDEF_S(bool);
-_TYPEDEF_S(char);
-_TYPEDEF_O(schar, signed char);
-_TYPEDEF_O(uchar, unsigned char);
-_TYPEDEF_S(short);
-_TYPEDEF_O(ushort, unsigned short);
-_TYPEDEF_S(int);
-_TYPEDEF_O(uint, unsigned int);
-_TYPEDEF_S(long);
-_TYPEDEF_O(ulong, unsigned long);
-_TYPEDEF_O(llong, long long);
-_TYPEDEF_O(ullong, unsigned long long);
-_TYPEDEF_T(char16);
-_TYPEDEF_T(char32);
-_TYPEDEF_T(wchar);
-_TYPEDEF_T(int_least8);
-_TYPEDEF_T(uint_least8);
-_TYPEDEF_T(int_least16);
-_TYPEDEF_T(uint_least16);
-_TYPEDEF_T(int_least32);
-_TYPEDEF_T(uint_least32);
-_TYPEDEF_T(int_least64);
-_TYPEDEF_T(uint_least64);
-_TYPEDEF_T(int_fast8);
-_TYPEDEF_T(uint_fast8);
-_TYPEDEF_T(int_fast16);
-_TYPEDEF_T(uint_fast16);
-_TYPEDEF_T(int_fast32);
-_TYPEDEF_T(uint_fast32);
-_TYPEDEF_T(int_fast64);
-_TYPEDEF_T(uint_fast64);
-_TYPEDEF_T(intptr);
-_TYPEDEF_T(uintptr);
-_TYPEDEF_T(size);
-_TYPEDEF_T(ptrdiff);
-_TYPEDEF_T(intmax);
-_TYPEDEF_T(uintmax);
-
-#undef ___TYPEDEF
-#undef _TYPEDEF_S
-#undef _TYPEDEF_T
-#undef _TYPEDEF_O
-
-#define arg                             \
-       {                                                \
-               .m = PTHREAD_MUTEX_INITIALIZER, .v = arg \
-       }
-
-#define atomic_init(obj, desired)          \
-       {                                  \
-               isc_mutex_init(&(obj)->m); \
-               (obj)->v = desired;        \
-       }
-#define atomic_load_explicit(obj, order)                               \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_store_explicit(obj, desired, order)                     \
-       {                                                              \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               (obj)->v = desired;                                    \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-       }
-#define atomic_fetch_add_explicit(obj, arg, order)                     \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               (obj)->v += arg;                                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_fetch_sub_explicit(obj, arg, order)                     \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               (obj)->v -= arg;                                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_fetch_and_explicit(obj, arg, order)                     \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               (obj)->v &= arg;                                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_fetch_or_explicit(obj, arg, order)                      \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               (obj)->v |= arg;                                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, \
-                                               fail)                         \
-       ({                                                                    \
-               bool ___v;                                                    \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);          \
-               ___v = ((obj)->v == *expected);                               \
-               *expected = (obj)->v;                                         \
-               (obj)->v = ___v ? desired : (obj)->v;                         \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS);        \
-               ___v;                                                         \
-       })
-#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, \
-                                             fail)                         \
-       ({                                                                  \
-               bool ___v;                                                  \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);        \
-               ___v = ((obj)->v == *expected);                             \
-               *expected = (obj)->v;                                       \
-               (obj)->v = ___v ? desired : (obj)->v;                       \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS);      \
-               ___v;                                                       \
-       })
-
-#define atomic_load(obj) atomic_load_explicit(obj, memory_order_seq_cst)
-#define atomic_store(obj, arg) \
-       atomic_store_explicit(obj, arg, memory_order_seq_cst)
-#define atomic_fetch_add(obj, arg) \
-       atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst)
-#define atomic_fetch_sub(obj, arg) \
-       atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst)
-#define atomic_fetch_and(obj, arg) \
-       atomic_fetch_and_explicit(obj, arg, memory_order_seq_cst)
-#define atomic_fetch_or(obj, arg) \
-       atomic_fetch_or_explicit(obj, arg, memory_order_seq_cst)
-#define atomic_compare_exchange_strong(obj, expected, desired)          \
-       atomic_compare_exchange_strong_explicit(obj, expected, desired, \
-                                               memory_order_seq_cst,   \
-                                               memory_order_seq_cst)
-#define atomic_compare_exchange_weak(obj, expected, desired)          \
-       atomic_compare_exchange_weak_explicit(obj, expected, desired, \
-                                             memory_order_seq_cst,   \
-                                             memory_order_seq_cst)
-#define atomic_exchange_explicit(obj, desired, order)                  \
-       ({                                                             \
-               typeof((obj)->v) ___v;                                 \
-               REQUIRE(isc_mutex_lock(&(obj)->m) == ISC_R_SUCCESS);   \
-               ___v = (obj)->v;                                       \
-               (obj)->v = desired;                                    \
-               REQUIRE(isc_mutex_unlock(&(obj)->m) == ISC_R_SUCCESS); \
-               ___v;                                                  \
-       })
-#define atomic_exchange(obj, desired) \
-       atomic_exchange_explicit(obj, desired, memory_order_seq_cst)
index 176c552b41da257d61a7bd775715b598bcb65ca6..54c850cb0f8a64c63b9c214877828e12afd7ee1f 100644 (file)
@@ -6220,14 +6220,6 @@ recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype,
        }
 }
 static atomic_uint_fast32_t last_soft, last_hard;
-#ifdef ISC_MUTEX_ATOMICS
-static isc_once_t last_once = ISC_ONCE_INIT;
-static void
-last_init() {
-       atomic_init(&last_soft, 0);
-       atomic_init(&last_hard, 0);
-}
-#endif /* ifdef ISC_MUTEX_ATOMICS */
 
 isc_result_t
 ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
@@ -6274,9 +6266,6 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
                }
 
                if (result == ISC_R_SOFTQUOTA) {
-#ifdef ISC_MUTEX_ATOMICS
-                       isc_once_do(&last_once, last_init);
-#endif /* ifdef ISC_MUTEX_ATOMICS */
                        isc_stdtime_t now;
                        isc_stdtime_get(&now);
                        if (now != atomic_load_relaxed(&last_soft)) {
@@ -6297,9 +6286,6 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
                        ns_client_killoldestquery(client);
                        result = ISC_R_SUCCESS;
                } else if (result == ISC_R_QUOTA) {
-#ifdef ISC_MUTEX_ATOMICS
-                       isc_once_do(&last_once, last_init);
-#endif /* ifdef ISC_MUTEX_ATOMICS */
                        isc_stdtime_t now;
                        isc_stdtime_get(&now);
                        if (now != atomic_load_relaxed(&last_hard)) {