mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
compatibility issue for MacOS X
This commit is contained in:
@@ -48,16 +48,12 @@ pgf_jit_alloc_page(PgfJitState* state)
|
|||||||
{
|
{
|
||||||
void *page;
|
void *page;
|
||||||
|
|
||||||
size_t page_size = sysconf(_SC_PAGESIZE);
|
size_t page_size = getpagesize();
|
||||||
total_size += page_size;
|
total_size += page_size;
|
||||||
|
|
||||||
if (posix_memalign(&page, page_size, page_size) != 0) {
|
if (posix_memalign(&page, page_size, page_size) != 0) {
|
||||||
gu_fatal("Memory allocation failed");
|
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);
|
PgfPageFinalizer* fin = gu_new(PgfPageFinalizer, state->pool);
|
||||||
fin->fin.fn = pgf_jit_finalize_page;
|
fin->fin.fn = pgf_jit_finalize_page;
|
||||||
@@ -85,7 +81,7 @@ pgf_jit_init(GuPool* tmp_pool, GuPool* pool)
|
|||||||
static void
|
static void
|
||||||
pgf_jit_make_space(PgfJitState* state)
|
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) {
|
if (jit_get_ip().ptr + JIT_CODE_WINDOW > ((char*) state->buf) + page_size) {
|
||||||
jit_flush_code(state->buf, jit_get_ip().ptr);
|
jit_flush_code(state->buf, jit_get_ip().ptr);
|
||||||
pgf_jit_alloc_page(state);
|
pgf_jit_alloc_page(state);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#ifndef __lightning_funcs_h
|
#ifndef __lightning_funcs_h
|
||||||
#define __lightning_funcs_h
|
#define __lightning_funcs_h
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -51,7 +51,7 @@ jit_flush_code(void *dest, void *end)
|
|||||||
execution of the data and stack segment are becoming more
|
execution of the data and stack segment are becoming more
|
||||||
and more common (Fedora, for example), so we implement our
|
and more common (Fedora, for example), so we implement our
|
||||||
jit_flush_code as an mprotect. */
|
jit_flush_code as an mprotect. */
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
static unsigned long prev_page = 0, prev_length = 0;
|
static unsigned long prev_page = 0, prev_length = 0;
|
||||||
unsigned long page, length;
|
unsigned long page, length;
|
||||||
#ifdef PAGESIZE
|
#ifdef PAGESIZE
|
||||||
@@ -59,7 +59,7 @@ jit_flush_code(void *dest, void *end)
|
|||||||
#else
|
#else
|
||||||
static int page_size = -1;
|
static int page_size = -1;
|
||||||
if (page_size == -1)
|
if (page_size == -1)
|
||||||
page_size = sysconf (_SC_PAGESIZE);
|
page_size = getpagesize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
page = (long) dest & ~(page_size - 1);
|
page = (long) dest & ~(page_size - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user