Commit 22e5231f authored by Ondřej Surý's avatar Ondřej Surý

Remove ISC_PLATFORM_BUSYWAITNOP in favour of direct isc_rwlock_pause() define

parent 376bea8b
......@@ -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?
#
......
......@@ -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?
#
......
......@@ -134,11 +134,6 @@
*/
@ISC_PLATFORM_HAVESYSUNH@
/*
* Define with the busy wait nop asm or function call.
*/
@ISC_PLATFORM_BUSYWAITNOP@
/*
* Define if the platform has <strings.h>.
*/
......
......@@ -41,6 +41,25 @@
#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;
......
......@@ -46,22 +46,14 @@
#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>.
*/
......@@ -73,35 +65,6 @@
#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.
......
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment