mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Merge pull request #1838 from mattsta/powerpc-fixes
PowerPC compile-time improvements
This commit is contained in:
commit
f86798ba6b
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user