From 09657334c048e3f9aec3bb2b86621d89402c3300 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 22 Sep 2008 21:55:05 -0400 Subject: [PATCH] fixed autoconf so that ffi.h and libffi are checked iff ffi is enabled. Also made prep-callback return #f if libffi does not support closures. --- configure | 24 ++++++++++++++---------- configure.ac | 19 +++++++++++-------- scheme/last-revision | 2 +- src/ikarus-ffi.c | 4 ++++ 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/configure b/configure index f371e15..695d1de 100755 --- a/configure +++ b/configure @@ -6650,13 +6650,12 @@ ac_cv_lib_gmp=ac_cv_lib_gmp_main # Check whether --enable-libffi was given. if test "${enable_libffi+set}" = set; then enableval=$enable_libffi; -cat >>confdefs.h <<\_ACEOF -#define ENABLE_LIBFFI 1 -_ACEOF - fi +if test "$enable_libffi" = "yes"; then + + for ac_header in ffi.h do as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -6804,8 +6803,7 @@ as_val=`eval 'as_val=${'$as_ac_Header'} _ACEOF else - if test "$enable_libffi" = "yes"; then - { { $as_echo "$as_me:$LINENO: error: ffi.h cannot be found. + { { $as_echo "$as_me:$LINENO: error: ffi.h cannot be found. Please specify the location of the header file using ./configure CFLAGS=-I " >&5 @@ -6814,12 +6812,12 @@ Please specify the location of the header file using ./configure CFLAGS=-I " >&2;} { (exit 1); exit 1; }; } - fi fi done + { $as_echo "$as_me:$LINENO: checking for ffi_call in -lffi" >&5 $as_echo_n "checking for ffi_call in -lffi... " >&6; } if test "${ac_cv_lib_ffi_ffi_call+set}" = set; then @@ -6893,8 +6891,7 @@ _ACEOF LIBS="-lffi $LIBS" else - if test "$enable_libffi" = "yes"; then - { { $as_echo "$as_me:$LINENO: error: libffi cannot be found. + { { $as_echo "$as_me:$LINENO: error: libffi cannot be found. Please specify the location of the library file using ./configure LDFLAGS=-L " >&5 @@ -6903,10 +6900,17 @@ Please specify the location of the library file using ./configure LDFLAGS=-L " >&2;} { (exit 1); exit 1; }; } - fi fi + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_LIBFFI 1 +_ACEOF + + +fi + # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } diff --git a/configure.ac b/configure.ac index 67e2d62..9034ff2 100644 --- a/configure.ac +++ b/configure.ac @@ -64,22 +64,25 @@ ERROR: libgmp.so) if libgmp is installed in a non-standard location. ERROR: libgmp can be obtained from . ])]) AC_ARG_ENABLE(libffi, - [ --enable-libffi enable support for libffi.], - AC_DEFINE(ENABLE_LIBFFI, 1, [adds support for libffi])) + [ --enable-libffi enable support for libffi.]) + +if test "$enable_libffi" = "yes"; then + AC_CHECK_HEADERS([ffi.h],, - if test "$enable_libffi" = "yes"; then AC_MSG_ERROR([ffi.h cannot be found. Please specify the location of the header file using ./configure CFLAGS=-I -]) - fi) +])) + AC_CHECK_LIB(ffi,ffi_call,, - if test "$enable_libffi" = "yes"; then AC_MSG_ERROR([libffi cannot be found. Please specify the location of the library file using ./configure LDFLAGS=-L -]) - fi) +])) + +AC_DEFINE(ENABLE_LIBFFI, 1, [adds support for libffi]) + +fi # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/scheme/last-revision b/scheme/last-revision index f70509d..3c8cfd3 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1601 +1602 diff --git a/src/ikarus-ffi.c b/src/ikarus-ffi.c index 7884a6d..694174a 100644 --- a/src/ikarus-ffi.c +++ b/src/ikarus-ffi.c @@ -319,6 +319,7 @@ generic_callback(ffi_cif *cif, void *ret, void **args, void *user_data){ ikptr ikrt_prepare_callback(ikptr data, ikpcb* pcb){ +#if FFI_CLOSURES ikptr cifptr = ref(data, off_vector_data + 0 * wordsize); void* codeloc; ffi_closure* closure = ffi_closure_alloc(sizeof(ffi_closure), &codeloc); @@ -346,6 +347,9 @@ ikrt_prepare_callback(ikptr data, ikpcb* pcb){ ref(p, 0) = pointer_tag; ref(p, wordsize) = (ikptr) codeloc; return p+vector_tag; +#else + return false_object +#endif } int ho (int(*f)(int), int n) {