From 3521c48f0d40c716b0a7898490e142d265c40062 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 21 Dec 2015 23:08:53 +0300 Subject: [PATCH] Bug #79487: Provide non-Windows implementations for LF_BACKOFF Add LF_BACKOFF implementations for GCC and Sun Studio + some minor code unification with InnoDB. --- include/atomic/generic-msvc.h | 26 ---------------- include/lf.h | 2 ++ include/my_atomic.h | 67 +++++++++++++++++++++++++++++++++++++--- include/my_compiler.h | 12 +++++++ storage/innobase/include/ut0ut.h | 46 ++++++++++----------------- 5 files changed, 93 insertions(+), 60 deletions(-) diff --git a/include/atomic/generic-msvc.h b/include/atomic/generic-msvc.h index 9fe2cdd..56de261 100644 --- a/include/atomic/generic-msvc.h +++ b/include/atomic/generic-msvc.h @@ -106,30 +106,4 @@ static inline void my_atomic_storeptr(void * volatile *a, void *v) (void)InterlockedExchangePointer(a, v); } - -/* - my_yield_processor (equivalent of x86 PAUSE instruction) should be used - to improve performance on hyperthreaded CPUs. Intel recommends to use it in - spin loops also on non-HT machines to reduce power consumption (see e.g - http://softwarecommunity.intel.com/articles/eng/2004.htm) - - Running benchmarks for spinlocks implemented with InterlockedCompareExchange - and YieldProcessor shows that much better performance is achieved by calling - YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting - loop count in the range 200-300 brought best results. - */ -#define YIELD_LOOPS 200 - -static inline int my_yield_processor() -{ - int i; - for (i=0; i + +# ifdef MY_PAUSE +# define UT_RELAX_CPU() MY_PAUSE() # else -# define UT_LOW_PRIORITY_CPU() ((void)0) -# define UT_RESUME_PRIORITY_CPU() ((void)0) +# error MY_PAUSE() is undefined # endif +#ifdef MY_LOW_PRIORITY_CPU +# define UT_LOW_PRIORITY_CPU() MY_LOW_PRIORITY_CPU() +#else +# error MY_LOW_PRIORITY_CPU() is undefined! +#endif + +#ifdef MY_RESUME_PRIORITY_CPU +# define UT_RESUME_PRIORITY_CPU() MY_RESUME_PRIORITY_CPU() +#else +# error MY_RESUME_PRIORITY_CPU() is undefined! +#endif + /*********************************************************************//** Delays execution for at most max_wait_us microseconds or returns earlier if cond becomes true.