summaryrefslogtreecommitdiff
path: root/src/atomicvar.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-05-04 17:00:53 +0200
committerantirez <antirez@gmail.com>2017-05-04 17:01:00 +0200
commit2a51bac44ebcff79dcd8ede2cab66ca213c9d504 (patch)
tree69267037fab3844dab3f77f17df9100acaeee1f5 /src/atomicvar.h
parent52bc74f22150183111bc0da9cd2c29de440a50b5 (diff)
downloadredis-2a51bac44ebcff79dcd8ede2cab66ca213c9d504.tar.gz
Simplify atomicvar.h usage by having the mutex name implicit.
Diffstat (limited to 'src/atomicvar.h')
-rw-r--r--src/atomicvar.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/atomicvar.h b/src/atomicvar.h
index c522db3e9..1efa7bffb 100644
--- a/src/atomicvar.h
+++ b/src/atomicvar.h
@@ -54,40 +54,40 @@
#if defined(__ATOMIC_RELAXED) && !defined(__sun) && (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057)
/* Implementation using __atomic macros. */
-#define atomicIncr(var,count,mutex) __atomic_add_fetch(&var,(count),__ATOMIC_RELAXED)
-#define atomicDecr(var,count,mutex) __atomic_sub_fetch(&var,(count),__ATOMIC_RELAXED)
-#define atomicGet(var,dstvar,mutex) do { \
+#define atomicIncr(var,count) __atomic_add_fetch(&var,(count),__ATOMIC_RELAXED)
+#define atomicDecr(var,count) __atomic_sub_fetch(&var,(count),__ATOMIC_RELAXED)
+#define atomicGet(var,dstvar) do { \
dstvar = __atomic_load_n(&var,__ATOMIC_RELAXED); \
} while(0)
#elif defined(HAVE_ATOMIC)
/* Implementation using __sync macros. */
-#define atomicIncr(var,count,mutex) __sync_add_and_fetch(&var,(count))
-#define atomicDecr(var,count,mutex) __sync_sub_and_fetch(&var,(count))
-#define atomicGet(var,dstvar,mutex) do { \
+#define atomicIncr(var,count) __sync_add_and_fetch(&var,(count))
+#define atomicDecr(var,count) __sync_sub_and_fetch(&var,(count))
+#define atomicGet(var,dstvar) do { \
dstvar = __sync_sub_and_fetch(&var,0); \
} while(0)
#else
/* Implementation using pthread mutex. */
-#define atomicIncr(var,count,mutex) do { \
- pthread_mutex_lock(&mutex); \
+#define atomicIncr(var,count) do { \
+ pthread_mutex_lock(&var ## _mutex); \
var += (count); \
- pthread_mutex_unlock(&mutex); \
+ pthread_mutex_unlock(&var ## _mutex); \
} while(0)
-#define atomicDecr(var,count,mutex) do { \
- pthread_mutex_lock(&mutex); \
+#define atomicDecr(var,count) do { \
+ pthread_mutex_lock(&var ## _mutex); \
var -= (count); \
- pthread_mutex_unlock(&mutex); \
+ pthread_mutex_unlock(&var ## _mutex); \
} while(0)
-#define atomicGet(var,dstvar,mutex) do { \
- pthread_mutex_lock(&mutex); \
+#define atomicGet(var,dstvar) do { \
+ pthread_mutex_lock(&var ## _mutex); \
dstvar = var; \
- pthread_mutex_unlock(&mutex); \
+ pthread_mutex_unlock(&var ## _mutex); \
} while(0)
#endif