MDEV-8684: Remove delaying maths in ut_delay

Also introduce compiler barrier properly on all architectures.
This commit is contained in:
Sergey Vojtovich 2016-03-30 14:42:12 +11:00 committed by Daniel Black
parent d4ba50477e
commit 3d1a7cba71
4 changed files with 14 additions and 18 deletions

View file

@ -89,9 +89,11 @@ private:
independent way by using YieldProcessor. */
# define UT_RELAX_CPU() YieldProcessor()
# else
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
# endif
#define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory")
# if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
@ -345,7 +347,7 @@ Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++.
@return dummy value */
UNIV_INTERN
ulint
void
ut_delay(
/*=====*/
ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */

View file

@ -394,25 +394,21 @@ Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++.
@return dummy value */
UNIV_INTERN
ulint
void
ut_delay(
/*=====*/
ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */
{
ulint i, j;
ulint i;
UT_LOW_PRIORITY_CPU();
j = 0;
for (i = 0; i < delay * 50; i++) {
j += i;
UT_RELAX_CPU();
UT_COMPILER_BARRIER();
}
UT_RESUME_PRIORITY_CPU();
return(j);
}
#endif /* !UNIV_HOTBACKUP */

View file

@ -86,9 +86,11 @@ private:
independent way by using YieldProcessor. */
# define UT_RELAX_CPU() YieldProcessor()
# else
# define UT_RELAX_CPU() __asm__ __volatile__ ("":::"memory")
# define UT_RELAX_CPU() ((void)0) /* avoid warning for an empty statement */
# endif
#define UT_COMPILER_BARRIER() __asm__ __volatile__ ("":::"memory")
# if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
# define UT_LOW_PRIORITY_CPU() __asm__ __volatile__ ("or 1,1,1")
# define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__ ("or 2,2,2")
@ -337,7 +339,7 @@ Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++.
@return dummy value */
UNIV_INTERN
ulint
void
ut_delay(
/*=====*/
ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */

View file

@ -395,25 +395,21 @@ Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++.
@return dummy value */
UNIV_INTERN
ulint
void
ut_delay(
/*=====*/
ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */
{
ulint i, j;
ulint i;
UT_LOW_PRIORITY_CPU();
j = 0;
for (i = 0; i < delay * 50; i++) {
j += i;
UT_RELAX_CPU();
UT_COMPILER_BARRIER();
}
UT_RESUME_PRIORITY_CPU();
return(j);
}
#endif /* !UNIV_HOTBACKUP */