summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrenJiang13 <yjjiang1996@163.com>2021-08-10 16:32:27 +0800
committerGitHub <noreply@github.com>2021-08-10 11:32:27 +0300
commit8ab33c18e4c34dbf2e894adca5b9e74fd4348587 (patch)
tree21cbd94819b44d75cfa635d6dc5cf4ac60607593
parent8f8117f78e004fa5f5808239dcaedf9acdb8c828 (diff)
downloadredis-8ab33c18e4c34dbf2e894adca5b9e74fd4348587.tar.gz
fix a compilation error around madvise when make with jemalloc on MacOS (#9350)
We only use MADV_DONTNEED on Linux, that's were it was tested.
-rw-r--r--src/object.c4
-rw-r--r--src/server.c4
-rw-r--r--src/zmalloc.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/object.c b/src/object.c
index a5705ea5a..2e27d69f6 100644
--- a/src/object.c
+++ b/src/object.c
@@ -537,9 +537,9 @@ void dismissObject(robj *o, size_t size_hint) {
/* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */
if (server.thp_enabled) return;
- /* Currently we use zmadvise_dontneed only when we use jemalloc.
+ /* Currently we use zmadvise_dontneed only when we use jemalloc with Linux.
* so we avoid these pointless loops when they're not going to do anything. */
-#if defined(USE_JEMALLOC)
+#if defined(USE_JEMALLOC) && defined(__linux__)
if (o->refcount != 1) return;
switch(o->type) {
case OBJ_STRING: dismissStringObject(o); break;
diff --git a/src/server.c b/src/server.c
index 301e21e28..3a4a1c3cc 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5987,9 +5987,9 @@ void dismissMemoryInChild(void) {
/* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */
if (server.thp_enabled) return;
- /* Currently we use zmadvise_dontneed only when we use jemalloc.
+ /* Currently we use zmadvise_dontneed only when we use jemalloc with Linux.
* so we avoid these pointless loops when they're not going to do anything. */
-#if defined(USE_JEMALLOC)
+#if defined(USE_JEMALLOC) && defined(__linux__)
/* Dismiss replication backlog. */
if (server.repl_backlog != NULL) {
diff --git a/src/zmalloc.c b/src/zmalloc.c
index 012dadd2f..b68f6b46a 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -346,7 +346,7 @@ void zmalloc_set_oom_handler(void (*oom_handler)(size_t)) {
* We do that in a fork child process to avoid CoW when the parent modifies
* these shared pages. */
void zmadvise_dontneed(void *ptr) {
-#if defined(USE_JEMALLOC)
+#if defined(USE_JEMALLOC) && defined(__linux__)
static size_t page_size = 0;
if (page_size == 0) page_size = sysconf(_SC_PAGESIZE);
size_t page_size_mask = page_size - 1;