Browse Source

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: Jimmy Yang <jimmy.yang@oracle.com>

Backported from MySQL-5.7 - patch 5e3efb0396

Suggestion by Stewart Smith
pull/168/head
Marko Mäkelä 10 years ago
committed by Daniel Black
parent
commit
2275640deb
  1. 7
      storage/innobase/include/ut0ut.h
  2. 7
      storage/innobase/ut/ut0ut.cc
  3. 7
      storage/xtradb/include/ut0ut.h
  4. 7
      storage/xtradb/ut/ut0ut.cc

7
storage/innobase/include/ut0ut.h

@ -88,13 +88,8 @@ private:
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
/*********************************************************************//**

7
storage/innobase/ut/ut0ut.cc

@ -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 */

7
storage/xtradb/include/ut0ut.h

@ -80,18 +80,13 @@ private:
# 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
/*********************************************************************//**

7
storage/xtradb/ut/ut0ut.cc

@ -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 */

Loading…
Cancel
Save