summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile2
-rw-r--r--unix/alloc.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/unix/Makefile b/unix/Makefile
index 04a2dbda17..9d035cab76 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -75,7 +75,7 @@ SRC_C = \
file.c \
modsocket.c \
modos.c \
- alloc.c \
+ alloc.c \
$(SRC_MOD)
ifeq ($(UNAME_S),Darwin)
diff --git a/unix/alloc.c b/unix/alloc.c
index 2c09f18461..cb866c78a2 100644
--- a/unix/alloc.c
+++ b/unix/alloc.c
@@ -30,8 +30,11 @@
#include "mpconfigport.h"
-void mp_unix_alloc_exec(mp_uint_t min_size, void** ptr, mp_uint_t *size)
-{
+#if defined(__OpenBSD__) || defined(__MACH__)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+void mp_unix_alloc_exec(mp_uint_t min_size, void **ptr, mp_uint_t *size) {
// size needs to be a multiple of the page size
*size = (min_size + 0xfff) & (~0xfff);
*ptr = mmap(NULL, *size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -40,7 +43,6 @@ void mp_unix_alloc_exec(mp_uint_t min_size, void** ptr, mp_uint_t *size)
}
}
-void mp_unix_free_exec(void *ptr, mp_uint_t size)
-{
+void mp_unix_free_exec(void *ptr, mp_uint_t size) {
munmap(ptr, size);
}