From c486455e0691f9915018b9d8b133200a6c61a3c5 Mon Sep 17 00:00:00 2001
From: Alistair Francis <alistair.francis@wdc.com>
Date: Thu, 24 May 2018 09:58:42 -0700
Subject: [PATCH] Remove atomics

Based on this patch:
https://github.com/patrikx3/lede-redis/blob/master/redis/patches/010-redis.patch

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 deps/jemalloc/src/pages.c | 22 +---------------------
 src/atomicvar.h           |  4 ++--
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/deps/jemalloc/src/pages.c b/deps/jemalloc/src/pages.c
index 83a167f6..8e82c78d 100644
--- a/deps/jemalloc/src/pages.c
+++ b/deps/jemalloc/src/pages.c
@@ -147,27 +147,7 @@ pages_purge(void *addr, size_t size)
 {
 	bool unzeroed;
 
-#ifdef _WIN32
-	VirtualAlloc(addr, size, MEM_RESET, PAGE_READWRITE);
-	unzeroed = true;
-#elif defined(JEMALLOC_HAVE_MADVISE)
-#  ifdef JEMALLOC_PURGE_MADVISE_DONTNEED
-#    define JEMALLOC_MADV_PURGE MADV_DONTNEED
-#    define JEMALLOC_MADV_ZEROS true
-#  elif defined(JEMALLOC_PURGE_MADVISE_FREE)
-#    define JEMALLOC_MADV_PURGE MADV_FREE
-#    define JEMALLOC_MADV_ZEROS false
-#  else
-#    error "No madvise(2) flag defined for purging unused dirty pages."
-#  endif
-	int err = madvise(addr, size, JEMALLOC_MADV_PURGE);
-	unzeroed = (!JEMALLOC_MADV_ZEROS || err != 0);
-#  undef JEMALLOC_MADV_PURGE
-#  undef JEMALLOC_MADV_ZEROS
-#else
-	/* Last resort no-op. */
-	unzeroed = true;
-#endif
+	unzeroed = false;
 	return (unzeroed);
 }
 
diff --git a/src/atomicvar.h b/src/atomicvar.h
index 84a5bbc5..f9b563c2 100644
--- a/src/atomicvar.h
+++ b/src/atomicvar.h
@@ -68,7 +68,7 @@
  * is reported. */
 // #define __ATOMIC_VAR_FORCE_SYNC_MACROS
 
-#if !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__ATOMIC_RELAXED) && !defined(__sun) && (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057)
+#if defined(CONFIG_EDAC_ATOMIC_SCRUB) &&  !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__ATOMIC_RELAXED) && !defined(__sun) && (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057)
 /* Implementation using __atomic macros. */
 
 #define atomicIncr(var,count) __atomic_add_fetch(&var,(count),__ATOMIC_RELAXED)
@@ -82,7 +82,7 @@
 #define atomicSet(var,value) __atomic_store_n(&var,value,__ATOMIC_RELAXED)
 #define REDIS_ATOMIC_API "atomic-builtin"
 
-#elif defined(HAVE_ATOMIC)
+#elif defined(CONFIG_EDAC_ATOMIC_SCRUB) && defined(HAVE_ATOMIC)
 /* Implementation using __sync macros. */
 
 #define atomicIncr(var,count) __sync_add_and_fetch(&var,(count))
-- 
2.17.0

