summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/runtime/c/pgf/jit.c8
-rw-r--r--src/runtime/c/pgf/lightning/i386/funcs.h6
2 files changed, 5 insertions, 9 deletions
diff --git a/src/runtime/c/pgf/jit.c b/src/runtime/c/pgf/jit.c
index 88363e73b..9889bf4e6 100644
--- a/src/runtime/c/pgf/jit.c
+++ b/src/runtime/c/pgf/jit.c
@@ -48,16 +48,12 @@ pgf_jit_alloc_page(PgfJitState* state)
{
void *page;
- size_t page_size = sysconf(_SC_PAGESIZE);
+ size_t page_size = getpagesize();
total_size += page_size;
if (posix_memalign(&page, page_size, page_size) != 0) {
gu_fatal("Memory allocation failed");
}
- if (mprotect(page, page_size,
- PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
- gu_fatal("mprotect failed");
- }
PgfPageFinalizer* fin = gu_new(PgfPageFinalizer, state->pool);
fin->fin.fn = pgf_jit_finalize_page;
@@ -85,7 +81,7 @@ pgf_jit_init(GuPool* tmp_pool, GuPool* pool)
static void
pgf_jit_make_space(PgfJitState* state)
{
- size_t page_size = sysconf(_SC_PAGESIZE);
+ size_t page_size = getpagesize();
if (jit_get_ip().ptr + JIT_CODE_WINDOW > ((char*) state->buf) + page_size) {
jit_flush_code(state->buf, jit_get_ip().ptr);
pgf_jit_alloc_page(state);
diff --git a/src/runtime/c/pgf/lightning/i386/funcs.h b/src/runtime/c/pgf/lightning/i386/funcs.h
index c35849956..bd9bfac4f 100644
--- a/src/runtime/c/pgf/lightning/i386/funcs.h
+++ b/src/runtime/c/pgf/lightning/i386/funcs.h
@@ -34,7 +34,7 @@
#ifndef __lightning_funcs_h
#define __lightning_funcs_h
-#ifdef __linux__
+#if defined(__linux__) || defined(__APPLE__)
#include <unistd.h>
#include <sys/mman.h>
#endif
@@ -51,7 +51,7 @@ jit_flush_code(void *dest, void *end)
execution of the data and stack segment are becoming more
and more common (Fedora, for example), so we implement our
jit_flush_code as an mprotect. */
-#ifdef __linux__
+#if defined(__linux__) || defined(__APPLE__)
static unsigned long prev_page = 0, prev_length = 0;
unsigned long page, length;
#ifdef PAGESIZE
@@ -59,7 +59,7 @@ jit_flush_code(void *dest, void *end)
#else
static int page_size = -1;
if (page_size == -1)
- page_size = sysconf (_SC_PAGESIZE);
+ page_size = getpagesize();
#endif
page = (long) dest & ~(page_size - 1);