aboutsummaryrefslogtreecommitdiff
path: root/src/lib/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/malloc')
-rw-r--r--src/lib/malloc/malloc.h4
-rw-r--r--src/lib/malloc/map_anon.c22
-rw-r--r--src/lib/malloc/map_anon.h2
3 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/malloc/malloc.h b/src/lib/malloc/malloc.h
index ef6b509ca4..8c81d30dd5 100644
--- a/src/lib/malloc/malloc.h
+++ b/src/lib/malloc/malloc.h
@@ -48,12 +48,12 @@ void tor_free_(void *mem);
raw_free(*tor_free__tmpvar); \
*tor_free__tmpvar=NULL; \
STMT_END
-#else
+#else /* !(defined(__GNUC__)) */
#define tor_free(p) STMT_BEGIN \
raw_free(p); \
(p)=NULL; \
STMT_END
-#endif
+#endif /* defined(__GNUC__) */
#define tor_malloc(size) tor_malloc_(size)
#define tor_malloc_zero(size) tor_malloc_zero_(size)
diff --git a/src/lib/malloc/map_anon.c b/src/lib/malloc/map_anon.c
index 6afea713df..0f6a4150c7 100644
--- a/src/lib/malloc/map_anon.c
+++ b/src/lib/malloc/map_anon.c
@@ -50,12 +50,16 @@
#ifdef INHERIT_ZERO
#define FLAG_ZERO INHERIT_ZERO
+#elif defined(MAP_INHERIT_ZERO)
+#define FLAG_ZERO MAP_INHERIT_ZERO
#endif
#ifdef INHERIT_NONE
#define FLAG_NOINHERIT INHERIT_NONE
#elif defined(VM_INHERIT_NONE)
#define FLAG_NOINHERIT VM_INHERIT_NONE
-#endif
+#elif defined(MAP_INHERIT_NONE)
+#define FLAG_NOINHERIT MAP_INHERIT_NONE
+#endif /* defined(INHERIT_NONE) || ... */
#elif defined(HAVE_MADVISE)
@@ -68,7 +72,7 @@
#define FLAG_NOINHERIT MADV_DONTFORK
#endif
-#endif
+#endif /* defined(HAVE_MINHERIT) || ... */
#if defined(HAVE_MINHERIT) && !defined(FLAG_ZERO) && !defined(FLAG_NOINHERIT)
#warn "minherit() is defined, but we couldn't find the right flag for it."
@@ -92,7 +96,7 @@ lock_mem(void *mem, size_t sz)
(void) sz;
return 0;
-#endif
+#endif /* defined(_WIN32) || ... */
}
/**
@@ -109,7 +113,7 @@ nodump_mem(void *mem, size_t sz)
(void) mem;
(void) sz;
return 0;
-#endif
+#endif /* defined(MADV_DONTDUMP) */
}
/**
@@ -131,19 +135,19 @@ noinherit_mem(void *mem, size_t sz, inherit_res_t *inherit_result_out)
*inherit_result_out = INHERIT_RES_ZERO;
return 0;
}
-#endif
+#endif /* defined(FLAG_ZERO) */
#ifdef FLAG_NOINHERIT
int r2 = MINHERIT(mem, sz, FLAG_NOINHERIT);
if (r2 == 0) {
*inherit_result_out = INHERIT_RES_DROP;
}
return r2;
-#else
+#else /* !(defined(FLAG_NOINHERIT)) */
(void)inherit_result_out;
(void)mem;
(void)sz;
return 0;
-#endif
+#endif /* defined(FLAG_NOINHERIT) */
}
/**
@@ -200,7 +204,7 @@ tor_mmap_anonymous(size_t sz, unsigned flags,
raw_assert(ptr != NULL);
#else
ptr = tor_malloc_zero(sz);
-#endif
+#endif /* defined(_WIN32) || ... */
if (flags & ANONMAP_PRIVATE) {
int lock_result = lock_mem(ptr, sz);
@@ -235,5 +239,5 @@ tor_munmap_anonymous(void *mapping, size_t sz)
#else
(void)sz;
tor_free(mapping);
-#endif
+#endif /* defined(_WIN32) || ... */
}
diff --git a/src/lib/malloc/map_anon.h b/src/lib/malloc/map_anon.h
index 6c02cd6c16..4c4690e12f 100644
--- a/src/lib/malloc/map_anon.h
+++ b/src/lib/malloc/map_anon.h
@@ -62,7 +62,7 @@ typedef enum {
#define NOINHERIT_CAN_FAIL
#else
#define NOINHERIT_CAN_FAIL
-#endif
+#endif /* defined(_WIN32) || ... */
void *tor_mmap_anonymous(size_t sz, unsigned flags,
inherit_res_t *inherit_result_out);