]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add --enable-pthread-rwlock option
authorWitold Kręcicki <wpk@isc.org>
Fri, 25 Jan 2019 11:29:52 +0000 (12:29 +0100)
committerOndřej Surý <ondrej@sury.org>
Thu, 30 May 2019 14:10:16 +0000 (16:10 +0200)
config.h.in
configure
configure.ac
lib/isc/include/isc/rwlock.h
lib/isc/rwlock.c

index cf742bc31c6da8b2999da5c3720ceb5868de0fa7..817fd003e5a72a52457a851e1c8e67f29c48fcae 100644 (file)
 /* define if PKCS11 is used for Public-Key Cryptography */
 #undef USE_PKCS11
 
+/* Define if you want to use pthread rwlock implementation */
+#undef USE_PTHREAD_RWLOCK
+
 /* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
index 24cca62c9cbcb8c1fcf7539f547e7eb2052c4d1c..425bb6a44c3953e61e890d1bc9dedb67bf23bfda 100755 (executable)
--- a/configure
+++ b/configure
@@ -900,6 +900,7 @@ enable_devpoll
 with_geoip
 with_locktype
 with_libtool
+enable_pthread_rwlock
 with_openssl
 enable_fips_mode
 with_cc_alg
@@ -1599,6 +1600,8 @@ Optional Features:
   --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]
+  --enable-pthread-rwlock use pthread rwlock instead of internal rwlock
+                          implementation (EXPERIMENTAL)
   --enable-fips-mode      enable FIPS mode in OpenSSL library [default=no]
   --enable-native-pkcs11  use native PKCS11 for public-key crypto [default=no]
   --enable-backtrace      log stack backtrace on abort [default=yes]
@@ -15615,7 +15618,19 @@ $as_echo "no" >&6; }
 esac
 
 
-for ac_func in pthread_rwlock_rdlock
+#
+# Do we want to use pthread rwlock? (useful for ThreadSanitizer)
+#
+# Check whether --enable-pthread_rwlock was given.
+if test "${enable_pthread_rwlock+set}" = set; then :
+  enableval=$enable_pthread_rwlock;
+else
+  enable_pthread_rwlock=no
+fi
+
+
+if test "$enable_pthread_rwlock" = "yes"; then :
+  for ac_func in pthread_rwlock_rdlock
 do :
   ac_fn_c_check_func "$LINENO" "pthread_rwlock_rdlock" "ac_cv_func_pthread_rwlock_rdlock"
 if test "x$ac_cv_func_pthread_rwlock_rdlock" = xyes; then :
@@ -15623,10 +15638,17 @@ if test "x$ac_cv_func_pthread_rwlock_rdlock" = xyes; then :
 #define HAVE_PTHREAD_RWLOCK_RDLOCK 1
 _ACEOF
 
+else
+  as_fn_error $? "pthread_rwlock_rdlock requested but not found" "$LINENO" 5
 fi
 done
 
 
+$as_echo "#define USE_PTHREAD_RWLOCK 1" >>confdefs.h
+
+
+fi
+
 CRYPTO=OpenSSL
 
 #
index 272706314eb64bffe6d13647f8132b10808ae2f5..7064846004c4f6f03de24442e3c481f9dc095e38 100644 (file)
@@ -733,7 +733,19 @@ case $use_libtool in
 esac
 AC_SUBST(INSTALL_LIBRARY)
 
-AC_CHECK_FUNCS([pthread_rwlock_rdlock])
+#
+# Do we want to use pthread rwlock? (useful for ThreadSanitizer)
+#
+AC_ARG_ENABLE([pthread_rwlock],
+             [AS_HELP_STRING([--enable-pthread-rwlock],
+                             [use pthread rwlock instead of internal rwlock implementation (EXPERIMENTAL)])],
+             [], [enable_pthread_rwlock=no])
+
+AS_IF([test "$enable_pthread_rwlock" = "yes"],
+      [AC_CHECK_FUNCS([pthread_rwlock_rdlock], [],
+                     [AC_MSG_ERROR([pthread_rwlock_rdlock requested but not found])])
+       AC_DEFINE([USE_PTHREAD_RWLOCK],[1],[Define if you want to use pthread rwlock implementation])
+      ])
 
 CRYPTO=OpenSSL
 
index 5551c1b6239d2196dd1bd8bbbb1e16c13609e499..d1a454533987f1caa2e6f52375245052817f80c0 100644 (file)
@@ -32,14 +32,14 @@ typedef enum {
        isc_rwlocktype_write
 } isc_rwlocktype_t;
 
-#if HAVE_PTHREAD_RWLOCK_RDLOCK
+#if USE_PTHREAD_RWLOCK
 
 struct isc_rwlock {
        pthread_rwlock_t        rwlock;
        atomic_bool             downgrade;
 };
 
-#else /* HAVE_PTHREAD_RWLOCK_RDLOCK */
+#else /* USE_PTHREAD_RWLOCK */
 
 struct isc_rwlock {
        /* Unlocked. */
@@ -78,7 +78,7 @@ struct isc_rwlock {
 
 };
 
-#endif /* HAVE_PTHREAD_RWLOCK_RDLOCK */
+#endif /* USE_PTHREAD_RWLOCK */
 
 isc_result_t
 isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
index 7d5e14ea4eb18587be37e6d1ffa6a08b275c1de4..d756d663abc0cb63887bafa8fef10e096f7de58b 100644 (file)
@@ -27,7 +27,7 @@
 #include <isc/rwlock.h>
 #include <isc/util.h>
 
-#if HAVE_PTHREAD_RWLOCK_RDLOCK
+#if USE_PTHREAD_RWLOCK
 
 #include <errno.h>
 #include <pthread.h>
@@ -645,4 +645,4 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
        return (ISC_R_SUCCESS);
 }
 
-#endif /* HAVE_PTHREAD_RWLOCK_RDLOCK */
+#endif /* USE_PTHREAD_RWLOCK */