Commit 900f489a authored by vasil's avatar vasil
parent 35bcc4ee
2009-07-02 The InnoDB Team
* include/ut0ut.h, plug.in, ut/ut0ut.c:
Use the PAUSE instruction inside the spinloop if it is available,
Thanks to Mikael Ronstrom <mikael@mysql.com>.
2009-06-29 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb_file_format.test,
......
......@@ -40,6 +40,21 @@ Created 1/20/1994 Heikki Tuuri
/** Time stamp */
typedef time_t ib_time_t;
#if defined(IB_HAVE_PAUSE_INSTRUCTION)
/* According to the gcc info page, asm volatile means that the
instruction has important side-effects and must not be removed.
Also asm volatile may trigger a memory barrier (spilling all registers
to memory). */
# define UT_RELAX_CPU() __asm__ __volatile__ ("pause")
#elif defined(HAVE_ATOMIC_BUILTINS)
# define UT_RELAX_CPU() do { \
volatile lint volatile_var; \
os_compare_and_swap_lint(&volatile_var, 0, 1); \
} while (0)
#else
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
#endif
/*********************************************************************//**
Delays execution for at most max_wait_us microseconds or returns earlier
if cond becomes true.
......
......@@ -123,6 +123,28 @@ MYSQL_PLUGIN_ACTIONS(innobase, [
])
])
])
# Check for x86 PAUSE instruction
AC_MSG_CHECKING("for x86 PAUSE instruction")
# We have to actually try running the test program, because of a bug
# in Solaris on x86_64, where it wrongly reports that PAUSE is not
# supported when trying to run an application. See
# http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
# We use ib_ prefix to avoid collisoins if this code is added to
# mysql's configure.in.
AC_TRY_RUN([
int main() {
__asm__ __volatile__ ("pause");
return(0);
}
],
[ib_x86_pause_exists=yes],
[ib_x86_pause_exists=no],
[ib_x86_pause_exists=no] # Cross-compile, assume no PAUSE instruction
)
if test "$ib_x86_pause_exists" = "yes"
then
AC_DEFINE([IB_HAVE_PAUSE_INSTRUCTION], [1], [Does x86 PAUSE instruction exist])
fi
])
# vim: set ft=config:
......@@ -391,6 +391,7 @@ ut_delay(
for (i = 0; i < delay * 50; i++) {
j += i;
UT_RELAX_CPU();
}
if (ut_always_false) {
......
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