Skip to content

Commit

Permalink
Bug#20045167 UT_DELAY MISSING COMPILER BARRIER
Browse files Browse the repository at this point in the history
UT_RELAX_CPU(): Use a compiler barrier.

ut_delay(): Remove the dummy global variable ut_always_false.

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

Backported from MySQL-5.7 - patch mysql/mysql-server@5e3efb0

Suggestion by Stewart Smith
  • Loading branch information
Marko Mäkelä authored and grooverdan committed Mar 31, 2016
1 parent 9f5b285 commit 2275640
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 26 deletions.
7 changes: 1 addition & 6 deletions storage/innobase/include/ut0ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*********************************************************************//**
Expand Down
7 changes: 0 additions & 7 deletions storage/innobase/ut/ut0ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -411,10 +408,6 @@ ut_delay(
UT_RELAX_CPU();
}

if (ut_always_false) {
ut_always_false = (ibool) j;
}

return(j);
}
#endif /* !UNIV_HOTBACKUP */
Expand Down
7 changes: 1 addition & 6 deletions storage/xtradb/include/ut0ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*********************************************************************//**
Expand Down
7 changes: 0 additions & 7 deletions storage/xtradb/ut/ut0ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -412,10 +409,6 @@ ut_delay(
UT_RELAX_CPU();
}

if (ut_always_false) {
ut_always_false = (ibool) j;
}

return(j);
}
#endif /* !UNIV_HOTBACKUP */
Expand Down

0 comments on commit 2275640

Please sign in to comment.