summaryrefslogtreecommitdiff
path: root/src/common/spinlock.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-07-10 15:38:09 +0200
committerHaru <haru@dotalux.com>2014-07-11 08:42:50 +0200
commit8b4f35532c8fd7c7f0939756923fdaf14ee39531 (patch)
tree2a5a69e909538ecc81cdcd37b0dd74e0a046e021 /src/common/spinlock.h
parent3f3f2e7ec09087b57148a0fb229de26293c5a462 (diff)
downloadhercules-8b4f35532c8fd7c7f0939756923fdaf14ee39531.tar.gz
hercules-8b4f35532c8fd7c7f0939756923fdaf14ee39531.tar.bz2
hercules-8b4f35532c8fd7c7f0939756923fdaf14ee39531.tar.xz
hercules-8b4f35532c8fd7c7f0939756923fdaf14ee39531.zip
Removed unsafe pointer typedefs
- If a variable doesn't look like a pointer... Maybe it might be a pointer after all. Please, give me back my '*' sign. - See CERT DCL05-C. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/spinlock.h')
-rw-r--r--src/common/spinlock.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index fe0da6669..5d57c6462 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -28,25 +28,25 @@ typedef struct __declspec( align(64) ) SPIN_LOCK{
volatile LONG lock;
volatile LONG nest;
volatile LONG sync_lock;
-} SPIN_LOCK, *PSPIN_LOCK;
+} SPIN_LOCK;
#else
typedef struct SPIN_LOCK{
volatile int32 lock;
volatile int32 nest; // nesting level.
volatile int32 sync_lock;
-} __attribute__((aligned(64))) SPIN_LOCK, *PSPIN_LOCK;
+} __attribute__((aligned(64))) SPIN_LOCK;
#endif
-static forceinline void InitializeSpinLock(PSPIN_LOCK lck){
+static forceinline void InitializeSpinLock(SPIN_LOCK *lck){
lck->lock = 0;
lck->nest = 0;
lck->sync_lock = 0;
}
-static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){
+static forceinline void FinalizeSpinLock(SPIN_LOCK *lck){
return;
}
@@ -54,7 +54,7 @@ static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){
#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){
+static forceinline void EnterSpinLock(SPIN_LOCK *lck){
int tid = rathread_get_tid();
// Get Sync Lock && Check if the requester thread already owns the lock.
@@ -84,7 +84,7 @@ static forceinline void EnterSpinLock(PSPIN_LOCK lck){
}
-static forceinline void LeaveSpinLock(PSPIN_LOCK lck){
+static forceinline void LeaveSpinLock(SPIN_LOCK *lck){
int tid = rathread_get_tid();
getsynclock(&lck->sync_lock);