Skip to content

Commit 2275640

Browse files
Marko Mäkelägrooverdan
authored andcommitted
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 mysql/mysql-server@5e3efb0 Suggestion by Stewart Smith
1 parent 9f5b285 commit 2275640

File tree

4 files changed

+2
-26
lines changed

4 files changed

+2
-26
lines changed

storage/innobase/include/ut0ut.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,8 @@ struct ut_when_dtor {
8888
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
8989
independent way by using YieldProcessor. */
9090
# define UT_RELAX_CPU() YieldProcessor()
91-
# elif defined(HAVE_ATOMIC_BUILTINS)
92-
# define UT_RELAX_CPU() do { \
93-
volatile lint volatile_var; \
94-
os_compare_and_swap_lint(&volatile_var, 0, 1); \
95-
} while (0)
9691
# else
97-
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
92+
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
9893
# endif
9994

10095
/*********************************************************************//**

storage/innobase/ut/ut0ut.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ Created 5/11/1994 Heikki Tuuri
4545
# include <string>
4646
#endif /* UNIV_HOTBACKUP */
4747

48-
/** A constant to prevent the compiler from optimizing ut_delay() away. */
49-
UNIV_INTERN ibool ut_always_false = FALSE;
50-
5148
#ifdef __WIN__
5249
/*****************************************************************//**
5350
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
@@ -411,10 +408,6 @@ ut_delay(
411408
UT_RELAX_CPU();
412409
}
413410

414-
if (ut_always_false) {
415-
ut_always_false = (ibool) j;
416-
}
417-
418411
return(j);
419412
}
420413
#endif /* !UNIV_HOTBACKUP */

storage/xtradb/include/ut0ut.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,13 @@ struct ut_when_dtor {
8080

8181
# elif defined(HAVE_FAKE_PAUSE_INSTRUCTION)
8282
# define UT_RELAX_CPU() __asm__ __volatile__ ("rep; nop")
83-
# elif defined(HAVE_ATOMIC_BUILTINS)
84-
# define UT_RELAX_CPU() do { \
85-
volatile lint volatile_var; \
86-
os_compare_and_swap_lint(&volatile_var, 0, 1); \
87-
} while (0)
8883
# elif defined(HAVE_WINDOWS_ATOMICS)
8984
/* In the Win32 API, the x86 PAUSE instruction is executed by calling
9085
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
9186
independent way by using YieldProcessor. */
9287
# define UT_RELAX_CPU() YieldProcessor()
9388
# else
94-
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
89+
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
9590
# endif
9691

9792
/*********************************************************************//**

storage/xtradb/ut/ut0ut.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ Created 5/11/1994 Heikki Tuuri
4646
# include <string>
4747
#endif /* UNIV_HOTBACKUP */
4848

49-
/** A constant to prevent the compiler from optimizing ut_delay() away. */
50-
UNIV_INTERN ibool ut_always_false = FALSE;
51-
5249
#ifdef __WIN__
5350
/*****************************************************************//**
5451
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
@@ -412,10 +409,6 @@ ut_delay(
412409
UT_RELAX_CPU();
413410
}
414411

415-
if (ut_always_false) {
416-
ut_always_false = (ibool) j;
417-
}
418-
419412
return(j);
420413
}
421414
#endif /* !UNIV_HOTBACKUP */

0 commit comments

Comments
 (0)