diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2014-06-26 15:13:49 +0200 |
---|---|---|
committer | Salvatore Sanfilippo <antirez@gmail.com> | 2014-06-26 15:13:49 +0200 |
commit | f86798ba6b3a0fb34109c55141c18997b55266b6 (patch) | |
tree | 18396347815e4363dde1c32399ed2e033ef00acf | |
parent | 9be3ee8283cffbb6cecc544a54db6c44a0e9cd45 (diff) | |
parent | a3e7a665ad62ab276b098c3c10460f111ea81200 (diff) | |
download | redis-f86798ba6b3a0fb34109c55141c18997b55266b6.tar.gz |
Merge pull request #1838 from mattsta/powerpc-fixes
PowerPC compile-time improvements
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/zmalloc.c | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/config.h b/src/config.h index 8041f7ebe..1bc70a13e 100644 --- a/src/config.h +++ b/src/config.h @@ -185,7 +185,7 @@ void setproctitle(const char *fmt, ...); #error "Undefined or invalid BYTE_ORDER" #endif -#if (__i386 || __amd64) && __GNUC__ +#if (__i386 || __amd64 || __powerpc__) && __GNUC__ #define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #if (GNUC_VERSION >= 40100) || defined(__clang__) #define HAVE_ATOMIC diff --git a/src/zmalloc.c b/src/zmalloc.c index d0cf726cb..11616e5ad 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -67,7 +67,10 @@ void zlibc_free(void *ptr) { #define free(ptr) je_free(ptr) #endif -#ifdef HAVE_ATOMIC +#if defined(__ATOMIC_RELAXED) +#define update_zmalloc_stat_add(__n) __atomic_add_fetch(&used_memory, (__n), __ATOMIC_RELAXED) +#define update_zmalloc_stat_sub(__n) __atomic_sub_fetch(&used_memory, (__n), __ATOMIC_RELAXED) +#elif defined(HAVE_ATOMIC) #define update_zmalloc_stat_add(__n) __sync_add_and_fetch(&used_memory, (__n)) #define update_zmalloc_stat_sub(__n) __sync_sub_and_fetch(&used_memory, (__n)) #else @@ -219,8 +222,8 @@ size_t zmalloc_used_memory(void) { size_t um; if (zmalloc_thread_safe) { -#ifdef HAVE_ATOMIC - um = __sync_add_and_fetch(&used_memory, 0); +#if defined(__ATOMIC_RELAXED) || defined(HAVE_ATOMIC) + um = update_zmalloc_stat_add(0); #else pthread_mutex_lock(&used_memory_mutex); um = used_memory; |