Commit 2275640d authored by Marko Mäkelä's avatar Marko Mäkelä Committed by Daniel Black

Bug#20045167 UT_DELAY MISSING COMPILER BARRIER

UT_RELAX_CPU(): Use a compiler barrier.

ut_delay(): Remove the dummy global variable ut_always_false.

RB: 11399
Reviewed-by: default avatarJimmy Yang <jimmy.yang@oracle.com>

Backported from MySQL-5.7 - patch https://github.com/mysql/mysql-server/commit/5e3efb03962838a13afbf1579abbb96aee48ad64

Suggestion by Stewart Smith
parent 9f5b2856
......@@ -88,13 +88,8 @@ struct ut_when_dtor {
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
independent way by using YieldProcessor. */
# define UT_RELAX_CPU() YieldProcessor()
# 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 */
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# endif
/*********************************************************************//**
......
......@@ -45,9 +45,6 @@ Created 5/11/1994 Heikki Tuuri
# include <string>
#endif /* UNIV_HOTBACKUP */
/** A constant to prevent the compiler from optimizing ut_delay() away. */
UNIV_INTERN ibool ut_always_false = FALSE;
#ifdef __WIN__
/*****************************************************************//**
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
......@@ -411,10 +408,6 @@ ut_delay(
UT_RELAX_CPU();
}
if (ut_always_false) {
ut_always_false = (ibool) j;
}
return(j);
}
#endif /* !UNIV_HOTBACKUP */
......
......@@ -80,18 +80,13 @@ struct ut_when_dtor {
# elif defined(HAVE_FAKE_PAUSE_INSTRUCTION)
# define UT_RELAX_CPU() __asm__ __volatile__ ("rep; nop")
# 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)
# elif defined(HAVE_WINDOWS_ATOMICS)
/* In the Win32 API, the x86 PAUSE instruction is executed by calling
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
independent way by using YieldProcessor. */
# define UT_RELAX_CPU() YieldProcessor()
# else
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# endif
/*********************************************************************//**
......
......@@ -46,9 +46,6 @@ Created 5/11/1994 Heikki Tuuri
# include <string>
#endif /* UNIV_HOTBACKUP */
/** A constant to prevent the compiler from optimizing ut_delay() away. */
UNIV_INTERN ibool ut_always_false = FALSE;
#ifdef __WIN__
/*****************************************************************//**
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
......@@ -412,10 +409,6 @@ ut_delay(
UT_RELAX_CPU();
}
if (ut_always_false) {
ut_always_false = (ibool) j;
}
return(j);
}
#endif /* !UNIV_HOTBACKUP */
......
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