diff --git a/c32 b/c32 index b4b790b..66b5b9e 100755 --- a/c32 +++ b/c32 @@ -2,7 +2,7 @@ ./configure \ --prefix=$HOME/.opt32 \ - CFLAGS="-m32 -I$HOME/.opt32/include -I$HOME/.opt32/lib/libffi-3.0.6/include" \ + CFLAGS="-m32 -I$HOME/.opt32/include -I$HOME/.opt32/lib/libffi-3.0.8/include" \ LDFLAGS="-m32 -L$HOME/.opt32/lib" \ && make clean \ && make diff --git a/c64 b/c64 index 27b5529..153b180 100755 --- a/c64 +++ b/c64 @@ -1,7 +1,7 @@ #!/usr/bin/env sh -./configure --prefix=/Users/ikarus/.opt \ - CFLAGS="-m64 -I $HOME/.opt64/include -I $HOME/.opt64/lib/libffi-3.0.6/include" \ +./configure --prefix=$HOME/.opt64 \ + CFLAGS="-m64 -I $HOME/.opt64/include -I $HOME/.opt64/lib/libffi-3.0.8/include" \ LDFLAGS="-m64 -L$HOME/.opt64/lib" \ && make clean \ && make diff --git a/config.h.in b/config.h.in index 8b81e47..d8683a5 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,11 @@ /* use flat segment and dirty vectors (not used yet) */ #undef FLAT_TABLES +/* Mark code returned by libffi executable because libffi does not do that + yet. This so far is only important on Snow Leopard in 64-bit mode but we + mark it on all darwins anyways. */ +#undef HACK_FFI + /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H @@ -153,9 +158,6 @@ /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O -/* Name of package */ -#undef PACKAGE - /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -186,9 +188,6 @@ /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME -/* Version number of package */ -#undef VERSION - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/configure b/configure index 2ba400d..151fc60 100755 --- a/configure +++ b/configure @@ -2996,15 +2996,6 @@ fi VERSION=0.0.4-rc1 -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} @@ -4931,6 +4922,11 @@ case "$target_os" in ;; *cygwin*) LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS" + ;; + *darwin*) + +$as_echo "#define HACK_FFI 1" >>confdefs.h + ;; esac diff --git a/configure.ac b/configure.ac index b99b163..35d75e8 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ(2.59) AC_INIT(ikarus, 0.0.4-rc1, aghuloum@cs.indiana.edu) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(ikarus, 0.0.4-rc1) +AM_INIT_AUTOMAKE(ikarus, 0.0.4-rc1, gnu) AC_CONFIG_SRCDIR([src/]) @@ -26,6 +26,13 @@ case "$target_os" in *cygwin*) LDFLAGS="-Wl,-E -Wl,--export-all-symbols $LDFLAGS" ;; + *darwin*) + AC_DEFINE(HACK_FFI, 1, + [Mark code returned by libffi executable because + libffi does not do that yet. This so far is only + important on Snow Leopard in 64-bit mode but we + mark it on all darwins anyways.]) + ;; esac AC_CHECK_SIZEOF(void *) diff --git a/src/ikarus-ffi.c b/src/ikarus-ffi.c index ffa94bc..12f1ab7 100644 --- a/src/ikarus-ffi.c +++ b/src/ikarus-ffi.c @@ -10,6 +10,10 @@ #undef DEBUG_FFI +#ifdef HACK_FFI +#include +#endif + static void* alloc(size_t n, int m) { void* x = calloc(n, m); @@ -435,6 +439,20 @@ ikrt_prepare_callback(ikptr data, ikpcb* pcb){ ikptr cifptr = ref(data, off_vector_data + 0 * wordsize); void* codeloc; ffi_closure* closure = ffi_closure_alloc(sizeof(ffi_closure), &codeloc); + +#ifdef HACK_FFI + { + long code_start = align_to_prev_page(codeloc); + long code_end = + align_to_next_page(FFI_TRAMPOLINE_SIZE+(-1)+(long)codeloc); + int rv = mprotect((void*)code_start, code_end - code_start, + PROT_READ|PROT_WRITE|PROT_EXEC); + if(rv) { + fprintf(stderr, "Error mprotecting code page!\n"); + } + } +#endif + ffi_cif* cif = (ffi_cif*) ref(cifptr, off_pointer_data); callback_locative* loc = malloc(sizeof(callback_locative));