]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove ISC_PLATFORM_BUSYWAITNOP in favour of direct isc_rwlock_pause() define
authorOndřej Surý <ondrej@sury.org>
Tue, 4 Sep 2018 10:26:39 +0000 (12:26 +0200)
committerOndřej Surý <ondrej@sury.org>
Fri, 7 Sep 2018 10:17:29 +0000 (12:17 +0200)
configure
configure.in
lib/isc/include/isc/platform.h.in
lib/isc/rwlock.c
lib/isc/win32/include/isc/platform.h.in
win32utils/Configure

index af0ab2596840bbad331333bc23aa9478f96496d1..7e7bdd9fae4a3bc49967ef273457da19ec54e43e 100755 (executable)
--- a/configure
+++ b/configure
@@ -706,7 +706,6 @@ DNSTAPSRCS
 DNSTAP
 FSTRM_CAPTURE
 PROTOC_C
-ISC_PLATFORM_BUSYWAITNOP
 ISC_PLATFORM_HAVEIFNAMETOINDEX
 ISC_PLATFORM_HAVESTRINGSH
 IRS_PLATFORM_USEDECLSPEC
@@ -18461,112 +18460,6 @@ $as_echo "#define HAVE_BUILTIN_CLZ 1" >>confdefs.h
 
 fi
 
-#
-# CPU relax (for spin locks)
-#
-case "$host" in
-i[3456]86-*)
-       # x86_32
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
-$as_echo_n "checking if asm(\"rep; nop\"); works... " >&6; }
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-asm("rep; nop");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       ;;
-x86_64-*|amd64-*)
-       # x86_64
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
-$as_echo_n "checking if asm(\"rep; nop\"); works... " >&6; }
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-asm("rep; nop");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       ;;
-ia64-*)
-       # ia64
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"hint @pause\"); works" >&5
-$as_echo_n "checking if asm(\"hint @pause\"); works... " >&6; }
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-asm("hint @pause");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       ;;
-sparc-*)
-       # sparc
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if cpu_relax(); or __cpu_relax(); works" >&5
-$as_echo_n "checking if cpu_relax(); or __cpu_relax(); works... " >&6; }
-       ac_fn_c_check_func "$LINENO" "cpu_relax" "ac_cv_func_cpu_relax"
-if test "x$ac_cv_func_cpu_relax" = xyes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"
-else
-  ac_fn_c_check_func "$LINENO" "__cpu_relax" "ac_cv_func___cpu_relax"
-if test "x$ac_cv_func___cpu_relax" = xyes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-          ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-fi
-
-       ;;
-esac
-
-
-
 #
 # Activate "rrset-order fixed" or not?
 #
index c1594e2c786266eee83b956965f17391f172d63e..c26cb4608b908ade8ef6b48724543d0e4e2e3222 100644 (file)
@@ -2275,55 +2275,6 @@ if test "yes" = "$have_builtin_clz"; then
        AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Define to 1 if the compiler supports __builtin_clz.])
 fi
 
-#
-# CPU relax (for spin locks)
-#
-case "$host" in
-[i[3456]86-*])
-       # x86_32
-       AC_MSG_CHECKING([if asm("rep; nop"); works])
-       AC_TRY_COMPILE(,[asm("rep; nop");],
-       [AC_MSG_RESULT(yes)
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
-       [AC_MSG_RESULT(no)],
-       [AC_MSG_RESULT([cross compile, assume yes])
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
-       ;;
-x86_64-*|amd64-*)
-       # x86_64
-       AC_MSG_CHECKING([if asm("rep; nop"); works])
-       AC_TRY_COMPILE(,[asm("rep; nop");],
-       [AC_MSG_RESULT(yes)
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
-       [AC_MSG_RESULT(no)],
-       [AC_MSG_RESULT([cross compile, assume yes])
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
-       ;;
-ia64-*)
-       # ia64
-       AC_MSG_CHECKING([if asm("hint @pause"); works])
-       AC_TRY_COMPILE(,[asm("hint @pause");],
-       [AC_MSG_RESULT(yes)
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"],
-       [AC_MSG_RESULT(no)],
-       [AC_MSG_RESULT([cross compile, assume yes])
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"])
-       ;;
-sparc-*)
-       # sparc
-       AC_MSG_CHECKING([if cpu_relax(); or __cpu_relax(); works])
-       AC_CHECK_FUNC(cpu_relax,
-       [AC_MSG_RESULT(yes)
-        ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"],
-        [AC_CHECK_FUNC(__cpu_relax,
-         [AC_MSG_RESULT(yes)
-          ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"],
-          [AC_MSG_RESULT(no)])])
-       ;;
-esac
-
-AC_SUBST(ISC_PLATFORM_BUSYWAITNOP)
-
 #
 # Activate "rrset-order fixed" or not?
 #
index 0280e438e7924fa43b4e207ae361c74b95e823f3..5fd9af3c5930ffe9becf23817bf59796005ab0f8 100644 (file)
  */
 @ISC_PLATFORM_HAVESYSUNH@
 
-/*
- * Define with the busy wait nop asm or function call.
- */
-@ISC_PLATFORM_BUSYWAITNOP@
-
 /*
  * Define if the platform has <strings.h>.
  */
index 622cd7d27626c559c8c833ecf9b5167d51764076..91482e6c6430e4bd2df20db757e415fc538708d6 100644 (file)
 #define RWLOCK_MAX_ADAPTIVE_COUNT 100
 #endif
 
+#if defined(_MSC_VER)
+# include <intrin.h>
+# define isc_rwlock_pause() YieldProcessor()
+#elif defined(__x86_64__) || defined(__i386__)
+# include <immintrin.h>
+# define isc_rwlock_pause() _mm_pause()
+#elif defined(__ia64__)
+# define isc_rwlock_pause() __asm__ __volatile__ ("hint @pause")
+#elif defined(__arm__)
+# define isc_rwlock_pause() __asm__ __volatile__ ("yield")
+#elif defined(__sparc) || defined(__sparc__)
+# define plasma_spin_pause() __asm__ __volatile__ ("pause")
+#elif defined(__ppc__) || defined(_ARCH_PPC)  ||                       \
+       defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
+# define isc_rwlock_pause() __asm__ volatile ("or 27,27,27")
+#else
+# define isc_rwlock_pause()
+#endif
+
 static isc_result_t
 isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
 
@@ -350,9 +369,7 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
                        result = isc__rwlock_lock(rwl, type);
                        break;
                }
-#ifdef ISC_PLATFORM_BUSYWAITNOP
-               ISC_PLATFORM_BUSYWAITNOP;
-#endif
+               isc_rwlock_pause();
        } while (isc_rwlock_trylock(rwl, type) != ISC_R_SUCCESS);
 
        rwl->spins += (cnt - rwl->spins) / 8;
index 8c4f9dc7950237c21f3601d8277e1d16e54f50ee..b36233a6952245815db8e29b46f64b42305a4740 100644 (file)
 
 #undef MSG_TRUNC
 
-#define ISC_PLATFORM_NEEDSTRSEP
 #define ISC_PLATFORM_NEEDSTRLCPY
 #define ISC_PLATFORM_NEEDSTRLCAT
-#define ISC_PLATFORM_NEEDSTRLCPY
 
 /*
  * Used to control how extern data is linked; needed for Win32 platforms.
  */
 #define ISC_PLATFORM_USEDECLSPEC 1
 
-/*
- * Define this here for now as winsock2.h defines h_errno
- * and we don't want to redeclare it.
- */
-#define ISC_PLATFORM_NONSTDHERRNO
-
 /*
  * Define if the platform has <sys/un.h>.
  */
 #define ISC_PLATFORM_NORETURN_PRE __declspec(noreturn)
 #define ISC_PLATFORM_NORETURN_POST
 
-/*
- * If the "xadd" operation is available on this architecture,
- * ISC_PLATFORM_HAVEXADD will be defined.
- */
-@ISC_PLATFORM_HAVEXADD@
-
-/*
- * If the "xaddq" operation (64bit xadd) is available on this architecture,
- * ISC_PLATFORM_HAVEXADDQ will be defined.
- */
-@ISC_PLATFORM_HAVEXADDQ@
-
-/*
- * If the "atomic swap" operation is available on this architecture,
- * ISC_PLATFORM_HAVEATOMICSTORE" will be defined.
- */
-@ISC_PLATFORM_HAVEATOMICSTORE@
-
-/*
- * If the "compare-and-exchange" operation is available on this architecture,
- * ISC_PLATFORM_HAVECMPXCHG will be defined.
- */
-@ISC_PLATFORM_HAVECMPXCHG@
-
-/*
- * Define with the busy wait nop asm or function call.
- */
-@ISC_PLATFORM_BUSYWAITNOP@
-
 /*
  * If the strcasestr() operation is not available on this platform,
  * ISC_PLATFORM_NEEDSTRCASESTR will be defined.
index a0015ae01ad8770ec40c3a86d3a4f156541aff22..eaa29247a139d7e2de6d86a592cfd80674bc4652 100644 (file)
@@ -220,19 +220,14 @@ my @substdefh = ("AES_CC",
                  "TUNE_LARGE",
                  "WANT_QUERYTRACE",
                  "WITH_IDN",
+                "CPU_RELAX",
                  "VALIDATION_DEFAULT");
 
 # for platform.h
 
 my %configdefp;
 
-my @substdefp = ("ISC_PLATFORM_BUSYWAITNOP",
-                 "ISC_PLATFORM_HAVEATOMICSTORE",
-                 "ISC_PLATFORM_HAVEATOMICSTOREQ",
-                 "ISC_PLATFORM_HAVECMPXCHG",
-                 "ISC_PLATFORM_HAVEXADD",
-                 "ISC_PLATFORM_HAVEXADDQ",
-                 "ISC_PLATFORM_NEEDSTRCASESTR");
+my @substdefp = ("ISC_PLATFORM_NEEDSTRCASESTR");
 
 # for conf.sh
 
@@ -576,13 +571,11 @@ if (($want_win32 eq "yes") && ($want_x64 eq "yes")) {
     $configvar{"BUILD_PLATFORM"} = "Win32";
     $configvar{"MACHINE"} = "/machine:X86";
     $configvar{"BUILD_MACHINE"} = "/machine:X86";
-    $configdefp{"ISC_PLATFORM_BUSYWAITNOP"} = "__asm { rep nop }";
 } elsif ($want_x64 eq "yes") {
     $configvar{"PLATFORM"} = "x64";
     $configvar{"BUILD_PLATFORM"} = "x64";
     $configvar{"MACHINE"} = "/machine:X64";
     $configvar{"BUILD_MACHINE"} = "/machine:X64";
-    $configdefp{"ISC_PLATFORM_BUSYWAITNOP"} = "_mm_pause()";
 }
 # Standard configure variable
 $configvar{"EXEEXT"} = ".exe";
@@ -1231,22 +1224,6 @@ EOF
 
 # Process arguments
 
-# enable-intrinsics
-if ($enable_intrinsics eq "yes") {
-    $configcond{"ATOMIC"} = 1;
-    $configvar{"INTRINSIC"} = "true";
-    $configvar{"COPTI"} = "/Oi";
-    $configdefp{"ISC_PLATFORM_HAVEXADD"} = 1;
-    if ($want_x64 eq "yes") {
-        $configdefp{"ISC_PLATFORM_HAVEXADDQ"} = 1;
-        $configdefp{"ISC_PLATFORM_HAVEATOMICSTOREQ"} = 1;
-    }
-    $configdefp{"ISC_PLATFORM_HAVEATOMICSTORE"} = 1;
-    $configdefp{"ISC_PLATFORM_HAVECMPXCHG"} = 1;
-} else {
-    $configvar{"INTRINSIC"} = "false";
-}
-
 # enable-native-pkcs11
 if ($enable_native_pkcs11 eq "yes") {
     $cryptolib = "pkcs11";