From 12dce46d611d6ea7c772174ebbd555fa10fead99 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 18 Nov 2013 08:53:22 +0100 Subject: Sanitized and improved several macros through the code - Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru --- src/common/spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/spinlock.h') diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 3419bfdd5..9b9e4ce94 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -52,8 +52,8 @@ static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){ } -#define getsynclock(l) { while(1){ if(InterlockedCompareExchange(l, 1, 0) == 0) break; rathread_yield(); } } -#define dropsynclock(l) { InterlockedExchange(l, 0); } +#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; rathread_yield(); } while(/*always*/1) +#define dropsynclock(l) do { InterlockedExchange((l), 0); } while(0) static forceinline void EnterSpinLock(PSPIN_LOCK lck){ int tid = rathread_get_tid(); -- cgit v1.2.3-60-g2f50