diff options
| author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-25 14:25:58 -0800 | 
|---|---|---|
| committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-01-25 14:25:58 -0800 | 
| commit | cbe647786f8631d32fc5f9226853950359207699 (patch) | |
| tree | 6a27e0f5ca4c32f7d50ad8d0acaa413c9ea2497c /indra | |
| parent | 2375afc4283e47a50516c1e003a6f699b0a2cfe1 (diff) | |
We already have a LL_FORCE_INLINE in llpreprocessor.h, don't re-invent it for llfasttimers.h.
Also define LL_LIKELY/LL_UNLIKELY with a warning about its micro-optimizey nature, and use it to annotate llasserts (i.e. make llassert() lower-overhead and thus more attractive, even in inner-ish loops.)
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llcommon/llerrorlegacy.h | 4 | ||||
| -rw-r--r-- | indra/llcommon/llfasttimer_class.h | 11 | ||||
| -rw-r--r-- | indra/llcommon/llpreprocessor.h | 15 | 
3 files changed, 19 insertions, 11 deletions
| diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h index 9920921a58..476d75380f 100644 --- a/indra/llcommon/llerrorlegacy.h +++ b/indra/llcommon/llerrorlegacy.h @@ -34,7 +34,7 @@  #ifndef LL_LLERRORLEGACY_H  #define LL_LLERRORLEGACY_H - +#include "llpreprocessor.h"  /*  	LEGACY -- DO NOT USE THIS STUFF ANYMORE @@ -107,7 +107,7 @@ const int LL_ERR_PRICE_MISMATCH = -23018;  #define llwarning(msg, num)		llwarns << "Warning # " << num << ": " << msg << llendl; -#define llassert_always(func)	if (!(func)) llerrs << "ASSERT (" << #func << ")" << llendl; +#define llassert_always(func)	if (LL_UNLIKELY(!(func))) llerrs << "ASSERT (" << #func << ")" << llendl;  #ifdef SHOW_ASSERT  #define llassert(func)			llassert_always(func) diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 4cb0c2d04e..ddb1a74793 100644 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -38,13 +38,6 @@  #define FAST_TIMER_ON 1  #define TIME_FAST_TIMERS 0 - -#if LL_WINDOWS -#define LL_INLINE __forceinline -#else -#define LL_INLINE -#endif // LL_WINDOWS -  class LLMutex;  #include <queue> @@ -164,7 +157,7 @@ public:  public:  	LLFastTimer(LLFastTimer::FrameState* state); -	LL_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) +	LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer)  	:	mFrameState(timer.mFrameState)  	{  #if TIME_FAST_TIMERS @@ -191,7 +184,7 @@ public:  #endif  	} -	LL_INLINE ~LLFastTimer() +	LL_FORCE_INLINE ~LLFastTimer()  	{  #if TIME_FAST_TIMERS  		U64 timer_start = getCPUClockCount64(); diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 5eefa6a16b..1c1503ca7b 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -55,13 +55,28 @@  #define LL_BIG_ENDIAN 1  #endif +  // Per-compiler switches +  #ifdef __GNUC__  #define LL_FORCE_INLINE inline __attribute__((always_inline))  #else  #define LL_FORCE_INLINE __forceinline  #endif +// Mark-up expressions with branch prediction hints.  Do NOT use +// this with reckless abandon - it's an obfuscating micro-optimization +// outside of inner loops or other places where you are OVERWHELMINGLY +// sure which way an expression almost-always evaluates. +#if __GNUC__ >= 3 +# define LL_LIKELY(EXPR) __builtin_expect (!!(EXPR), true) +# define LL_UNLIKELY(EXPR) __builtin_expect (!!(EXPR), false) +#else +# define LL_LIKELY(EXPR) (EXPR) +# define LL_UNLIKELY(EXPR) (EXPR) +#endif + +  // Figure out differences between compilers  #if defined(__GNUC__)  	#define GCC_VERSION (__GNUC__ * 10000 \ | 
