Commit 0d9349f6 authored by Erick Gallesio's avatar Erick Gallesio

Added option --disable-ffi to configure

parent 07992798
......@@ -116,6 +116,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
/*
C/Invoke Source Code File
Copyright (c) 2006 Will Weisser
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef CINVOKE_BUILD
#include "../cinvoke.h"
#include "../cinvoke-private.h"
#else
#include "cinvoke.h"
#include "cinvoke-private.h"
#endif
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
void arch_free_errstr(char *str) {
free(str);
}
cinv_status_t arch_library_create(CInvContext *context, const char *path,
ArchLibrary *library_out) {
void *dl = dlopen(path, RTLD_LAZY);
if (!dl) {
context_set_error(context, -1, strdup(dlerror()), 1);
return CINV_ERROR;
}
library_out->dl = dl;
return CINV_SUCCESS;
}
cinv_status_t arch_library_get_entrypoint(CInvContext *context,
ArchLibrary *library, const char *name, void **entrypoint_out) {
void *sym = dlsym(library->dl, name);
if (!sym) {
context_set_error(context, -1, strdup(dlerror()), 1);
return CINV_ERROR;
}
*entrypoint_out = sym;
return CINV_SUCCESS;
}
cinv_status_t arch_library_delete(CInvContext *context, ArchLibrary *library) {
if (dlclose(library->dl)) {
context_set_error(context, -1, strdup(dlerror()), 1);
return CINV_ERROR;
}
return CINV_SUCCESS;
}
const static int LEN = 4096;
char *arch_callback_stub(void *functionp, void *param,
short stacksize, cinv_callconv_t cc, cinv_type_t types[], int numparams) {
char *ret = mmap(0, LEN, PROT_EXEC|PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0);
if (ret == MAP_FAILED)
return NULL;
// void f() { ((void (*)(void *))0xAAAAAAAA)((void *)0xBBBBBBBB); }
memcpy(ret,
"\x55\x89\xe5\x83\xec\x08\x83\xec\x0c\x68"
"\xbb\xbb\xbb\xbb\xb8\xaa\xaa\xaa\xaa\xff"
"\xd0\x83\xc4\x10\xc9\xc3",
26);
memcpy(ret + 10, &param, 4);
memcpy(ret + 15, &functionp, 4);
return ret;
}
void arch_free_stub(char *stub) {
munmap(stub, LEN);
}
int arch_is_register_parm(cinv_callconv_t callingconvention, int index,
int num_params, cinv_type_t types[]) { return 0; }
void arch_set_register_parms(ArchRegParms *regparms,
cinv_callconv_t callingconvention, int num_params, void *parameters[],
cinv_type_t types[]) {}
void arch_get_register_parms(ArchRegParms *regparms,
cinv_callconv_t callingconvention, int num_params, void *parameters_out[],
cinv_type_t types[]) {}
void arch_getval_char(ArchRetValue *archval, char *outval) {
*outval = archval->ivallow;
}
void arch_getval_short(ArchRetValue *archval, short *outval) {
*outval = archval->ivallow;
}
void arch_getval_int(ArchRetValue *archval, int *outval) {
*outval = archval->ivallow;
}
void arch_getval_long(ArchRetValue *archval, long int *outval) {
*outval = archval->ivallow;
}
void arch_getval_extralong(ArchRetValue *archval, long long int *outval) {
*outval = archval->ivalhigh;
*outval <<= 32;
*outval |= archval->ivallow;
}
void arch_getval_float(ArchRetValue *archval, float *outval) {
*outval = (float)archval->dval;
}
void arch_getval_double(ArchRetValue *archval, double *outval) {
*outval = archval->dval;
}
void arch_getval_ptr(ArchRetValue *archval, void **outval) {
*outval = (void *)archval->ivallow;
}
void arch_setval_char(ArchRetValue *archval, char val) {
archval->ivallow = val;
}
void arch_setval_short(ArchRetValue *archval, short val) {
archval->ivallow = val;
}
void arch_setval_int(ArchRetValue *archval, int val) {
archval->ivallow = val;
}
void arch_setval_long(ArchRetValue *archval, long int val) {
archval->ivallow = val;
}
void arch_setval_extralong(ArchRetValue *archval, long long int val) {
archval->ivalhigh = (val >> 32);
archval->ivallow = val;
}
void arch_setval_float(ArchRetValue *archval, float val) {
archval->dval = val;
}
void arch_setval_double(ArchRetValue *archval, double val) {
archval->dval = val;
}
void arch_setval_ptr(ArchRetValue *archval, void *val) {
archval->ivallow = (int)val;
}
void arch_size_char(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 1;
}
void arch_size_short(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 2;
*structalign_out = 2;
}
void arch_size_int(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 4;
*structalign_out = 4;
}
void arch_size_long(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 4;
*structalign_out = 4;
}
void arch_size_extralong(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 8;
*structsize_out = 8;
*structalign_out = 4;
}
void arch_size_float(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 4;
*structalign_out = 4;
}
void arch_size_double(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 8;
*structsize_out = 8;
*structalign_out = 4;
}
void arch_size_ptr(int *stacksize_out, int *structsize_out,
int *structalign_out) {
*stacksize_out = 4;
*structsize_out = 4;
*structalign_out = 4;
}
/*
C/Invoke Source Code File
Copyright (c) 2006 Will Weisser
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ARCH_GCC_X86_UNIX_H
#define _ARCH_GCC_X86_UNIX_H
#include <errno.h>
typedef struct _ArchLibrary {
void *dl;
} ArchLibrary;
typedef struct _ArchRetValue {
int ivallow;
int ivalhigh;
double dval;
} ArchRetValue;
typedef struct _ArchRegParms {} ArchRegParms;
typedef char cinv_int8_t;
typedef short cinv_int16_t;
typedef int cinv_int32_t;
typedef long long cinv_int64_t;
#define CINV_E_NOMEM ((cinv_int32_t)ENOMEM)
#define CINV_S_NOMEM (strerror(ENOMEM))
#define CINV_NOMEM_NEEDSFREE 0
#define CINV_E_INVAL ((cinv_int32_t)EINVAL)
#define CINV_CC_DEFAULT CINV_CC_CDECL
#define CINV_T_2BYTE CINV_T_SHORT
#define CINV_T_4BYTE CINV_T_INT
#define CINV_T_8BYTE CINV_T_EXTRALONG
/////////////////////////////////////
// macros
/////////////////////////////////////
#define ARCH_SAVE_REGPARMS(regparms)
#define ARCH_CALL(regparms, ep) ((void (*)())ep)();
#define ARCH_SAVE_RETURN(archvalue, type) \
__asm__("movl %%eax, %0; \
movl %%edx, %1" : \
"=m" ((archvalue).ivallow), \
"=m" ((archvalue).ivalhigh)); \
if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { \
__asm__("fstpl %0" : \
"=m" ((archvalue).dval)); \
}
#define ARCH_SET_RETURN(archvalue, type) \
if (type == CINV_T_FLOAT || type == CINV_T_DOUBLE) { \
__asm__("fldl %0" :: \
"m" ((archvalue).dval) : \
"%st"); \
} \
__asm__("movl %0, %%eax; \
movl %1, %%edx" :: \
"m" ((archvalue).ivallow), \
"m" ((archvalue).ivalhigh) : \
"%eax", "%edx");
#define ARCH_PUT_STACK_BYTES(bcount) \
__asm__("subl %0, %%esp" :: "m" (bcount) : "%esp");
#define ARCH_REMOVE_STACK_BYTES(bcount) \
__asm__("addl %0, %%esp" :: "m" (bcount) : "%esp");
#define ARCH_GET_STACK(sp) \
__asm__("movl %%esp, %0" : "=m" (sp));
#define ARCH_GET_FRAME_PTR(fp) \
__asm__("movl %%ebp, %0" : "=m" (fp));
#define ARCH_CALLBACK_ARG_OFFSET (4*10)
#define ARCH_BIG_ENDIAN 0
#define ARCH_STACK_GROWS_DOWN 1
#define ARCH_STACK_SKIPTOP 0
#define ARCH_REGPARMS_IN_STACKSIZE 0
#define ARCH_CLAMP_NONFIRST_STRUCTALIGN 0
#endif
......@@ -82,6 +82,9 @@ typedef enum _cinv_callconv_t {
#ifdef ARCH_GCC_SPARC_UNIX
#include "arch/gcc_sparc_unix.h"
#endif
#ifdef ARCH_GCC_X86_OSX
#include "arch/gcc_x86_osx.h"
#endif
#ifndef CINVOKE_BUILD
#include "cinvoke-archspec.h"
#endif
......
......@@ -704,6 +704,7 @@ LIBOBJS
PERLINT
STKCFLAGS
HAVE_DLOPEN
HAVE_FFI
OS_FLAVOUR
GC
GCLIB
......@@ -1332,6 +1333,7 @@ Optional Features:
--enable-ldap enable ldap
--disable-gtk disable gtk support
--disable-gnome disable gnome support
--disable-ffi disable FFI support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
......@@ -6778,7 +6780,7 @@ fi
# *) PCRETARGET="libpcre.la libpcreposix.la";;
# esac
## C/INVOKE
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
......@@ -6819,19 +6821,29 @@ fi
if test "$PERLINT" = "yes" ;then
# We have perl. We can try to configure C/invoke
# Check whether --enable-ffi was given.
if test "${enable_ffi+set}" = set; then
enableval=$enable_ffi; USER_FFI="no"
else
USER_FFI="yes"
fi
if test "$PERLINT" = "yes" -a "$USER_FFI" = "yes" ;then
# We have perl and user did't disable FFI. We can try to configure C/invoke
echo "Configuring C/Invoke"
(cd cinvoke; perl configure.pl --prefix=$prefix)
LIBS="$LIBS ../cinvoke/lib/libcinvoke.a"
CFLAGS="$CFLAGS -I../cinvoke/lib"
CINVOKE="cinvoke"
HAVE_FFI="#define HAVE_FFI 1"
FFI="yes"
else
echo "No perl interpreter. Disabling FFI support"
echo "Disabling FFI support"
CINVOKE=""
HAVE_FFI=""
FFI="no"
fi
FFI=$PERLINT
......@@ -6964,6 +6976,7 @@ fi
ac_config_files="$ac_config_files Makefile src/Makefile src/extraconf.h doc/Makefile lib/Makefile gtklos/Makefile gtklos/gtklosconf.h utils/Makefile lib/boot-callcc.stk utils/stklos-config utils/stklos-script extensions/Makefile examples/Makefile examples/images/Makefile lib/Match.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile lib/Lurc.d/Makefile lib/ScmPkg.d/Makefile tests/Makefile extensions/extconf.h doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1 doc/stklos-genlex.1 doc/stklos-install.1 doc/stklos-pkg.1 doc/skb/stklos-version.stk pkgman/Makefile"
......@@ -7750,12 +7763,12 @@ LIBOBJS!$LIBOBJS$ac_delim
PERLINT!$PERLINT$ac_delim
STKCFLAGS!$STKCFLAGS$ac_delim
HAVE_DLOPEN!$HAVE_DLOPEN$ac_delim
HAVE_FFI!$HAVE_FFI$ac_delim
OS_FLAVOUR!$OS_FLAVOUR$ac_delim
GC!$GC$ac_delim
GCLIB!$GCLIB$ac_delim
GCINC!$GCINC$ac_delim
GMP!$GMP$ac_delim
GMPLIB!$GMPLIB$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
......@@ -7797,6 +7810,7 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
GMPLIB!$GMPLIB$ac_delim
GMPINC!$GMPINC$ac_delim
PREFIX!$PREFIX$ac_delim
SCMDIR!$SCMDIR$ac_delim
......@@ -7832,7 +7846,7 @@ CINVOKE!$CINVOKE$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 33; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 34; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
......
......@@ -2,7 +2,7 @@ dnl configure.in for STklos
dnl
dnl Author: Erick Gallesio [eg@unice.fr]
dnl Creation date: 28-Dec-1999 21:19 (eg)
dnl Last file update: 19-Jun-2007 12:07 (eg)
dnl Last file update: 28-Jun-2007 18:37 (eg)
AC_INIT(src/stklos.c)
......@@ -384,23 +384,32 @@ fi
# *) PCRETARGET="libpcre.la libpcreposix.la";;
# esac
## C/INVOKE
dnl
dnl FFI support
dnl
AC_CHECK_PROG(PERLINT, [perl], "yes", "no")
if test "$PERLINT" = "yes" ;then
# We have perl. We can try to configure C/invoke
AC_ARG_ENABLE(ffi,
[ --disable-ffi disable FFI support],
USER_FFI="no", USER_FFI="yes")
if test "$PERLINT" = "yes" -a "$USER_FFI" = "yes" ;then
# We have perl and user did't disable FFI. We can try to configure C/invoke
echo "Configuring C/Invoke"
(cd cinvoke; perl configure.pl --prefix=$prefix)
LIBS="$LIBS ../cinvoke/lib/libcinvoke.a"
CFLAGS="$CFLAGS -I../cinvoke/lib"
CINVOKE="cinvoke"
HAVE_FFI="#define HAVE_FFI 1"
FFI="yes"
else
echo "No perl interpreter. Disabling FFI support"
echo "Disabling FFI support"
CINVOKE=""
HAVE_FFI=""
FFI="no"
fi
FFI=$PERLINT
dnl ======================================================================
......@@ -509,6 +518,7 @@ dnl Output files
AC_SUBST(STKCFLAGS)
AC_SUBST(VERSION)
AC_SUBST(HAVE_DLOPEN)
AC_SUBST(HAVE_FFI)
AC_SUBST(OS_FLAVOUR)
AC_SUBST(GC)
AC_SUBST(GCLIB)
......
......@@ -110,6 +110,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
stklos-ref.html
\ No newline at end of file
......@@ -96,6 +96,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -92,6 +92,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -102,6 +102,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -120,6 +120,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -99,6 +99,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -116,6 +116,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -111,6 +111,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -98,6 +98,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -98,6 +98,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -100,6 +100,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -100,6 +100,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
......@@ -150,6 +150,7 @@ GTK_CONFIG = @GTK_CONFIG@
GTK_CONFIG_CFLAGS = @GTK_CONFIG_CFLAGS@
GTK_CONFIG_LIBS = @GTK_CONFIG_LIBS@
HAVE_DLOPEN = @HAVE_DLOPEN@
HAVE_FFI = @HAVE_FFI@
HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@
INSTALL = @INSTALL@
......
/* -*- C -*-
* extra.h -- Extra pre-processor definitions
*
* Copyright 2000-2005 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
* Copyright 2000-2007 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
* This program is free software; you can redistribute it and/or modify
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 19-May-2000 18:44 (eg)
* Last file update: 30-Mar-2005 13:22 (eg)
* Last file update: 28-Jun-2007 17:58 (eg)
*/
#define PREFIXDIR "@PREFIX@"
......@@ -36,5 +36,6 @@
/* Various stuff */
@HAVE_DLOPEN@
@HAVE_FFI@
@DEF_PCRE@
#define @OS_FLAVOUR@ 1
......@@ -21,11 +21,13 @@
*
* Author: Erick Gallesio [eg@essi.fr]
* Creation date: 14-Jun-2007 09:19 (eg)
* Last file update: 25-Jun-2007 15:21 (eg)
* Last file update: 28-Jun-2007 18:26 (eg)
*/
#include <stklos.h>
#include <cinvoke.h>
#ifdef HAVE_FFI
# include <cinvoke.h>
/* ------------------------------ *\
* STklos C external functions
......@@ -439,7 +441,7 @@ static int exec_callback(SCM callback, ...)
param.ulvalue = va_arg(ap, unsigned long); break;
case 8: /* lonlong */
case 9: /* ulonlong */
STk_debug("long long in a callback are not implemented yet");
STk_error("long long in a callback are not implemented yet");
case 10: /* float */
param.fvalue = (float) va_arg(ap, double); break;
case 11: /* double */
......@@ -454,7 +456,7 @@ static int exec_callback(SCM callback, ...)
case 16: /* int16 */
case 17: /* int32 */
case 18: /* int64 */
STk_debug("argument of type ~S in callback are not implemented yet",
STk_error("argument of type ~S in callback are not implemented yet",
CAR(Cargs));
case 19: /* obj */
param.pvalue = va_arg(ap, void *); break;
......@@ -487,6 +489,23 @@ DEFINE_PRIMITIVE("%exec-callback-address", exec_cb_addr, subr0, (void))
return z;
}
#else /* HAVE_FFI */
static void error_no_ffi(void)
{
STk_error("current system does not support FFI");
}
DEFINE_PRIMITIVE("%make-ext-func", make_ext_func, subr4,
(SCM p1, SCM p2, SCM p3, SCM p4))
{ error_no_ffi(); return STk_void;}
DEFINE_PRIMITIVE("make-callback", make_callback, subr3, (SCM p1, SCM p2, SCM p3))
{ error_no_ffi(); return STk_void;}
DEFINE_PRIMITIVE("%exec-callback-address", exec_cb_addr, subr0, (void))
{ error_no_ffi(); return STk_void;}
#endif
/* ======================================================================
* INIT ...
......
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: ??-Oct-1993 ??:??
* Last file update: 21-Jun-2007 16:51 (eg)
* Last file update: 28-Jun-2007 18:21 (eg)
*
*/
#include <ctype.h>
......@@ -213,6 +213,7 @@ void STk_print(SCM exp, SCM port, int mode)
STk_puts(PRIMITIVE_NAME(exp), port);
STk_putc(']', port);
return;
#ifdef HAVE_FFI
case tc_ext_func:
STk_puts("#[external-func ", port);
STk_puts(STRING_CHARS(STk_ext_func_name(exp)), port);
......@@ -222,6 +223,7 @@ void STk_print(SCM exp, SCM port, int mode)
sprintf(buffer, "#[callback %lx]", (unsigned long) exp);
STk_puts(buffer, port);
return;
#endif
default:
{
struct extended_type_descr *xdescr = BOXED_XTYPE(exp);
......
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@kaolin.unice.fr]
* Creation date: 15-Nov-1993 22:02
* Last file update: 15-Jun-2007 12:15 (eg)
* Last file update: 28-Jun-2007 18:23 (eg)
*/
#include "stklos.h"
......@@ -141,9 +141,11 @@ DEFINE_PRIMITIVE("%procedure-name", procedure_name, subr1, (SCM obj))
case tc_subr01:
case tc_subr12:
case tc_subr23:
case tc_vsubr:
case tc_apply: return STk_Cstring2string(PRIMITIVE_NAME(obj));
case tc_vsubr: return STk_ext_func_name(obj);
case tc_ext_func: return STk_ext_func_name(obj);
#ifdef HAVE_FFI
case tc_ext_func: return STk_ext_func_name(obj);
#endif
case tc_closure: if (CLOSURE_NAME(obj) != STk_false)
return STk_Cstring2string(SYMBOL_PNAME(CLOSURE_NAME(obj)));
/* NO BREAK */
......
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 1-Mar-2000 19:51 (eg)
* Last file update: 15-Jun-2007 11:56 (eg)