summaryrefslogtreecommitdiff
path: root/shared/loki/Threads.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
commit8bf668665b107469086f16cb8ad23e47d479d2b4 (patch)
tree66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/loki/Threads.h
parent3.21 (diff)
downloadFreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip
4.0
Diffstat (limited to 'shared/loki/Threads.h')
-rw-r--r--shared/loki/Threads.h354
1 files changed, 177 insertions, 177 deletions
diff --git a/shared/loki/Threads.h b/shared/loki/Threads.h
index 8fb5d362..690ca50f 100644
--- a/shared/loki/Threads.h
+++ b/shared/loki/Threads.h
@@ -92,97 +92,97 @@
#define LOKI_THREADS_MUTEX_CTOR(x)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval *= val; \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval /= val; \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicIncrement(volatile IntType& lval) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- ++lval; \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDecrement(volatile IntType& lval) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- --lval; \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static void AtomicAssign(volatile IntType& lval, const IntType val) \
- { InterlockedExchange(&const_cast<IntType&>(lval), val); } \
- \
- static void AtomicAssign(IntType& lval, volatile const IntType& val) \
- { InterlockedExchange(&lval, val); } \
- \
- static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- ++lval; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- --lval; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval += val; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval -= val; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval *= val; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::EnterCriticalSection( &atomic_mutex_ ); \
- lval /= val; \
- matches = ( lval == compare ); \
- ::LeaveCriticalSection( &atomic_mutex_ ); \
- return lval; \
- }
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval *= val; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval /= val; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ ++lval; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ --lval; \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static void AtomicAssign(volatile IntType& lval, const IntType val) \
+ { InterlockedExchange(&const_cast<IntType&>(lval), val); } \
+ \
+ static void AtomicAssign(IntType& lval, volatile const IntType& val) \
+ { InterlockedExchange(&lval, val); } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ ++lval; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ --lval; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval += val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval -= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval *= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::EnterCriticalSection( &atomic_mutex_ ); \
+ lval /= val; \
+ matches = ( lval == compare ); \
+ ::LeaveCriticalSection( &atomic_mutex_ ); \
+ return lval; \
+ }
#elif defined(LOKI_PTHREAD_H)
@@ -206,96 +206,96 @@
#define LOKI_THREADS_LONG long
#define LOKI_THREADS_ATOMIC(x) \
- pthread_mutex_lock(&atomic_mutex_); \
- x; \
- pthread_mutex_unlock(&atomic_mutex_)
+ pthread_mutex_lock(&atomic_mutex_); \
+ x; \
+ pthread_mutex_unlock(&atomic_mutex_)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \
private: \
- static pthread_mutex_t atomic_mutex_; \
+ static pthread_mutex_t atomic_mutex_; \
public: \
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval *= val; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval /= val; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicIncrement(volatile IntType& lval) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- ++lval; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDecrement(volatile IntType& lval) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- --lval; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static void AtomicAssign(volatile IntType& lval, const IntType val) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval = val; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static void AtomicAssign(IntType& lval, volatile const IntType& val) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval = val; \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- ++lval; \
- matches = ( compare == lval ); \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- --lval; \
- matches = ( compare == lval ); \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval *= val; \
- matches = ( lval == compare ); \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- } \
- \
- static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
- { \
- ::pthread_mutex_lock( &atomic_mutex_ ); \
- lval /= val; \
- matches = ( lval == compare ); \
- ::pthread_mutex_unlock( &atomic_mutex_ ); \
- return lval; \
- }
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval *= val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval /= val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ ++lval; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ --lval; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static void AtomicAssign(volatile IntType& lval, const IntType val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval = val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static void AtomicAssign(IntType& lval, volatile const IntType& val) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval = val; \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ ++lval; \
+ matches = ( compare == lval ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ --lval; \
+ matches = ( compare == lval ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval *= val; \
+ matches = ( lval == compare ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ } \
+ \
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \
+ { \
+ ::pthread_mutex_lock( &atomic_mutex_ ); \
+ lval /= val; \
+ matches = ( lval == compare ); \
+ ::pthread_mutex_unlock( &atomic_mutex_ ); \
+ return lval; \
+ }
#else // single threaded
bgstack15