Commit 01ebcdb5 authored by Erick Gallesio's avatar Erick Gallesio

* Current-{input,output,error}-port are now thread specific.

* Start the integration of Stephane Épardaud LURC stuff.
parent 2c423af9
2006-04-13 Erick Gallesio <eg@essi.fr>
* src/error.c, src/fport.c, src/gnu-getopt.c, src/hash.c,
* src/port.c, src/process.c, src/stklos.h:
Current-{input,output,error}-port are now thread specific.
* src/stklosconf.h.in, src/thread.c, src/thread.h, src/vm.h,
* lib/Lurc.d: Start the integration of Stephane pardaud LURC stuff.
2006-04-06 Erick Gallesio <eg@essi.fr> 2006-04-06 Erick Gallesio <eg@essi.fr>
* lib/bonus.stk (parameterize): * lib/bonus.stk, src/lib.c, src/parameter.c, src/stklos.h,
* src/lib.c * src/thread.c, src/vm.c,
* src/parameter.c
* src/stklos.h
* src/thread.c
* src/vm.c
* src/vm.h: New implementetaion of parameters. Paramateres can now * src/vm.h: New implementetaion of parameters. Paramateres can now
be assocaited to a thread. PARAMETERIZE permits to have a thread be assocaited to a thread. PARAMETERIZE permits to have a thread
specific dynamic environment. specific dynamic environment.
......
...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@ ...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@/STklos SVN_URL = @SVN_URL@/STklos
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ dnl configure.in for STklos ...@@ -2,7 +2,7 @@ dnl configure.in for STklos
dnl dnl
dnl Author: Erick Gallesio [eg@unice.fr] dnl Author: Erick Gallesio [eg@unice.fr]
dnl Creation date: 28-Dec-1999 21:19 (eg) dnl Creation date: 28-Dec-1999 21:19 (eg)
dnl Last file update: 4-Jan-2006 16:18 (eg) dnl Last file update: 13-Apr-2006 13:25 (eg)
AC_INIT(src/stklos.c) AC_INIT(src/stklos.c)
...@@ -47,9 +47,66 @@ then ...@@ -47,9 +47,66 @@ then
HAVE_DLOPEN="#define HAVE_DLOPEN 1" HAVE_DLOPEN="#define HAVE_DLOPEN 1"
fi fi
dnl Check for pthreads dnl
AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS") dnl To thread or not to thread ?
dnl
AC_ARG_ENABLE(threads,
[AC_HELP_STRING([--enable-threads=TYPE], [choose threading package (none,pthread,lurc)])],
THREADS=$enableval,
THREADS=none)
AC_LANG(C)
dnl This checks for the presence of a given CPP define in a fiven header file
AC_DEFUN(GC_CHECK_DEFINE, [
dnl $1: header file
dnl $2: CPP variable
dnl $3: then
dnl $4: else
AC_PREPROC_IFELSE([
#include <$1>
#ifndef $2
# error "$2 undefined"
#else
ok
#endif
],
[$3], [$4])
])
dnl Now look at what threads we want
case "$THREADS" in
no | none | single)
THREADS=none
AC_DEFINE(THREADS_NONE, [], [No thread support])
;;
posix | pthreads)
dnl Check for pthreads
AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS",
[AC_MSG_ERROR([Missing PThread library])])
THREADS=pthreads
AC_DEFINE(THREADS_PTHREADS, [], [PThread support])
;;
lurc)
dnl Check for lurc
AC_CHECK_LIB(lurc, lurc_thread_create, LIBS="-llurc $LIBS",
[AC_MSG_ERROR([Missing LURC library])])
AC_CHECK_HEADER([lurc.h], [], [AC_MSG_ERROR([Missing LURC header file])])
dnl Now check if it is compiled with GC support
AC_MSG_CHECKING([for LURC GC support])
GC_CHECK_DEFINE([lurc.h], [LURC_ENABLE_GC],
[AC_MSG_RESULT([ok])],
[AC_MSG_ERROR([Missing GC support in LURC])])
dnl That should be good
AC_DEFINE(THREADS_LURC, [], [LURC threads support])
;;
*)
AC_MSG_ERROR([Unknown thread system: $THREADS])
;;
esac
dnl Automake nightmare
AM_CONDITIONAL(PTHREADS, test "$THREADS" = pthreads)
AM_CONDITIONAL(LURC, test "$THREADS" = lurc)
AM_CONDITIONAL(NO_THREAD, test "$THREADS" = none)
dnl check for GMP pre-version 3.0 dnl check for GMP pre-version 3.0
AC_CHECK_LIB(gmp, mpz_init_set, HAVE_GMP="yes", HAVE_GMP="no") AC_CHECK_LIB(gmp, mpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")
...@@ -68,7 +125,13 @@ AC_ARG_WITH(gmp-light, ...@@ -68,7 +125,13 @@ AC_ARG_WITH(gmp-light,
dnl dnl
dnl check for GC dnl check for GC
dnl dnl
AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS) if test "$THREADS" = lurc
then
AC_MSG_WARN([Using the bundled GC for LURC support])
HAVE_GC="no"
else
AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS)
fi
# Test if the user want to force with our GC # Test if the user want to force with our GC
AC_ARG_WITH(provided-gc, AC_ARG_WITH(provided-gc,
...@@ -241,13 +304,15 @@ then ...@@ -241,13 +304,15 @@ then
case `uname -s` in case `uname -s` in
Darwin*) echo "Force GC compilation without optimizations on MacOS"; Darwin*) echo "Force GC compilation without optimizations on MacOS";
(cd gc; CC="$CC" CFLAGS="-g" sh ./configure --prefix=$prefix \ (cd gc; CC="$CC" CFLAGS="-g" sh ./configure --prefix=$prefix \
--disable-threads) ;; --disable-threads) || { echo "Cannot configure the GC"; exit; } ;;
*) (cd gc; CC="$CC" CFLAGS="$CFLAGS" sh ./configure --prefix=$prefix) ;; *) (cd gc; CC="$CC" CFLAGS="$CFLAGS" sh ./configure --prefix=$prefix \
--enable-threads=$THREADS) || { echo "Cannot configure the GC"; exit; } ;;
esac esac
GC=gc GC=gc
GCLIB="../gc/.libs/libgc.a" GCLIB="../gc/.libs/libgc.a"
GCINC="-I../gc" GCINC="-I../gc/include"
AC_DEFINE(HAVE_GC, [], [Use system GC])
# Eventually add a distclean target to the GC Makefile # Eventually add a distclean target to the GC Makefile
else else
echo "Using the system Boehm-Demers-Weiser library" echo "Using the system Boehm-Demers-Weiser library"
...@@ -379,6 +444,13 @@ if test "$SVN_REPOSITORY" = "" ;then ...@@ -379,6 +444,13 @@ if test "$SVN_REPOSITORY" = "" ;then
SVN_URL="NOT_AVAILABLE" SVN_URL="NOT_AVAILABLE"
fi fi
# LURC adjustment
LURCDIR=""
if test "$THREADS" = "lurc" ;then
LURCDIR=Lurc.d
fi
dnl Output files dnl Output files
AC_SUBST(VERSION) AC_SUBST(VERSION)
...@@ -386,6 +458,7 @@ AC_SUBST(HAVE_DLOPEN) ...@@ -386,6 +458,7 @@ AC_SUBST(HAVE_DLOPEN)
AC_SUBST(OS_FLAVOUR) AC_SUBST(OS_FLAVOUR)
AC_SUBST(GC) AC_SUBST(GC)
AC_SUBST(GCLIB) AC_SUBST(GCLIB)
AC_SUBST(GCINC)
AC_SUBST(GMP) AC_SUBST(GMP)
AC_SUBST(GMPLIB) AC_SUBST(GMPLIB)
AC_SUBST(GMPINC) AC_SUBST(GMPINC)
...@@ -416,6 +489,9 @@ AC_SUBST(PCRELIB) ...@@ -416,6 +489,9 @@ AC_SUBST(PCRELIB)
AC_SUBST(PCREINC) AC_SUBST(PCREINC)
AC_SUBST(DEF_PCRE) AC_SUBST(DEF_PCRE)
AC_SUBST(SVN_URL) AC_SUBST(SVN_URL)
AC_SUBST(THREADS)
AC_SUBST(LURCDIR)
AC_OUTPUT(Makefile src/Makefile src/extraconf.h doc/Makefile AC_OUTPUT(Makefile src/Makefile src/extraconf.h doc/Makefile
lib/Makefile gtklos/Makefile gtklos/gtklosconf.h lib/Makefile gtklos/Makefile gtklos/gtklosconf.h
...@@ -423,7 +499,7 @@ AC_OUTPUT(Makefile src/Makefile src/extraconf.h doc/Makefile ...@@ -423,7 +499,7 @@ AC_OUTPUT(Makefile src/Makefile src/extraconf.h doc/Makefile
utils/stklos-config utils/stklos-script utils/stklos-config utils/stklos-script
extensions/Makefile examples/Makefile extensions/Makefile examples/Makefile
examples/images/Makefile lib/Match.d/Makefile examples/images/Makefile lib/Match.d/Makefile
lib/SILex.d/Makefile lib/Lalr.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile lib/Lurc.d/Makefile
tests/Makefile extensions/extconf.h tests/Makefile extensions/extconf.h
doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1 doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1
doc/stklos-genlex.1 doc/stklos-install.1 doc/stklos-genlex.1 doc/stklos-install.1
...@@ -446,6 +522,7 @@ echo " GC library: " $gclib ...@@ -446,6 +522,7 @@ echo " GC library: " $gclib
echo " LDAP support: " $USE_LDAP echo " LDAP support: " $USE_LDAP
echo " GTK+ support: " $USE_GTK echo " GTK+ support: " $USE_GTK
echo " GNOME support: " $USE_GNOME echo " GNOME support: " $USE_GNOME
echo " Thread support: " $THREADS
echo " " echo " "
echo "If this is correct, you can just type 'make' now at your shell prompt." echo "If this is correct, you can just type 'make' now at your shell prompt."
echo "Otherwise, re-run 'configure' with correct options." echo "Otherwise, re-run 'configure' with correct options."
......
...@@ -82,6 +82,7 @@ DEPDIR = @DEPDIR@ ...@@ -82,6 +82,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -96,6 +97,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -96,6 +97,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -114,6 +116,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -114,6 +116,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
...@@ -75,6 +75,7 @@ DEPDIR = @DEPDIR@ ...@@ -75,6 +75,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -89,6 +90,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -89,6 +90,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -107,6 +109,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -107,6 +109,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
...@@ -75,6 +75,7 @@ DEPDIR = @DEPDIR@ ...@@ -75,6 +75,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -89,6 +90,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -89,6 +90,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -107,6 +109,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -107,6 +109,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@ ...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
...@@ -82,6 +82,7 @@ DEPDIR = @DEPDIR@ ...@@ -82,6 +82,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -96,6 +97,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -96,6 +97,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -114,6 +116,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -114,6 +116,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@ ...@@ -81,6 +81,7 @@ DEPDIR = @DEPDIR@
EXAMPLES = @EXAMPLES@ EXAMPLES = @EXAMPLES@
EXECDIR = @EXECDIR@ EXECDIR = @EXECDIR@
GC = @GC@ GC = @GC@
GCINC = @GCINC@
GCLIB = @GCLIB@ GCLIB = @GCLIB@
GMP = @GMP@ GMP = @GMP@
GMPINC = @GMPINC@ GMPINC = @GMPINC@
...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@ ...@@ -95,6 +96,7 @@ HAVE_GNOME = @HAVE_GNOME@
HAVE_LDAP = @HAVE_LDAP@ HAVE_LDAP = @HAVE_LDAP@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@ LDAP_LIB = @LDAP_LIB@
LURCDIR = @LURCDIR@
OS_FLAVOUR = @OS_FLAVOUR@ OS_FLAVOUR = @OS_FLAVOUR@
OS_NAME = @OS_NAME@ OS_NAME = @OS_NAME@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@ ...@@ -113,6 +115,7 @@ SH_SUFFIX = @SH_SUFFIX@
STACK_DIRECTION = @STACK_DIRECTION@ STACK_DIRECTION = @STACK_DIRECTION@
STRIP = @STRIP@ STRIP = @STRIP@
SVN_URL = @SVN_URL@ SVN_URL = @SVN_URL@
THREADS = @THREADS@
VERSION = @VERSION@ VERSION = @VERSION@
am__include = @am__include@ am__include = @am__include@
am__quote = @am__quote@ am__quote = @am__quote@
......
# Makefile.am for STklos Lurc directory
#
# Author: Stephane Epardaud [Stephane.Epardaud@inria.fr]
# Creation date: 3-Apr-2006 10:30 (se)
# Last file update: 13-Apr-2006 17:31 (eg)
CC = @CC@
CFLAGS = @CFLAGS@
MGCINC = $(subst ../,../../,@GCINC@)
STKCONF = ../../utils/stklos-config
INCLUDES = -I../../src $(COMPFLAGS) $(MGCINC)
COMPILE = @CC@ @CFLAGS@ @SH_COMP_FLAGS@ $(INCLUDES)
shobjectdir=$(prefix)/lib/@PACKAGE@/@VERSION@
shobject_SCRIPTS = stklurc.@SH_SUFFIX@
noinst_LIBRARIES = libstklurc.a
libstklurc_a_SOURCES = lurc.c
# Scheme part
schemedir = $(prefix)/share/@PACKAGE@/@VERSION@
scheme_files = lurc.stk
scheme_DATA = $(scheme_files) lursk.ostk
stklurc.@SH_SUFFIX@: libstklurc.a
@CC@ @SH_LOAD_FLAGS@ stklurc.@SH_SUFFIX@ $(libstklurc_a_OBJECTS)
chmod 0755 stklurc.@SH_SUFFIX@
lurc.ostk: $(scheme_files)
../../utils/tmpcomp lurc.stk lurc.ostk
clean:
/bin/rm -f *.o *.ostk *.@SH_SUFFIX@ *.a *~
distclean: clean
This diff is collapsed.
#include <lurc.h>
#include <stklos.h>
//
// Signal type definition
static int tc_signal;
struct signal_obj {
stk_header header;
lurc_signal_t sig;
};
#define SIGNALP(p) (BOXED_TYPE_EQ((p), tc_signal))
#define SIGNAL_SIG(p) (((struct signal_obj *) (p))->sig)
static void print_signal(SCM signal, SCM port, int mode)
{
char *name = (char*)lurc_signal_name(&SIGNAL_SIG(signal));
STk_puts("#[signal ", port);
if (*name)
STk_puts(name, port);
else
STk_fprintf(port, "%lx", (unsigned long) signal);
STk_putc(']', port);
}
/* The stucture which describes the signal type */
static struct extended_type_descr xtype_signal = {
"lurc:signal", /* name */
print_signal /* print function */
};
//
// Errors
static void error_bad_signal(SCM obj)
{
STk_error("bad signal ~S", obj);
}
static void lurc_error(int ret)
{
STk_error("lurc error ~a", lurc_strerror(ret));
}
//
// Primitives
DEFINE_PRIMITIVE("lurc:signal?", lurc_signalp, subr1, (SCM obj))
{
return MAKE_BOOLEAN(SIGNALP(obj));
}
DEFINE_PRIMITIVE("lurc:signal-name", lurc_signal_name, subr1, (SCM sig))
{
char *name;
if (! SIGNALP(sig)) error_bad_signal(sig);
name = (char*)lurc_signal_name(&SIGNAL_SIG(sig));
if(name == NULL)
name = "";
return STk_Cstring2string(name);
}
static void signal_finalizer(SCM sig)
{
lurc_signal_destroy(&SIGNAL_SIG(sig));
}
static SCM do_make_signal(char *name)
{
SCM z;
lurc_signal_attr_t attr;
int ret;
if((ret = lurc_signal_attr_init(&attr)) != 0)
lurc_error(ret);
if((ret = lurc_signal_attr_setname(&attr, name)) != 0){
lurc_signal_attr_destroy(&attr);
lurc_error(ret);
}
NEWCELL(z, signal);
if((ret = lurc_signal_init(&SIGNAL_SIG(z), &attr)) != 0){
lurc_signal_attr_destroy(&attr);
lurc_error(ret);
}
if((ret = lurc_signal_attr_destroy(&attr)) != 0){
lurc_signal_destroy(&SIGNAL_SIG(z));
lurc_error(ret);
}
STk_register_finalizer(z, signal_finalizer);
return z;
}
DEFINE_PRIMITIVE("lurc:signal", lurc_make_signal, subr01, (SCM name))
{
SCM z;
char *s;
if (name) {
if (!STRINGP(name))
STk_error("bad signal name ~S", name);
s = STRING_CHARS(name);
}
else s = NULL;
z = do_make_signal(s);
return z;
}
static void
enter_context(void *arg){
SCM thunk = (SCM)arg;
STk_C_apply(thunk, 0);
}
DEFINE_PRIMITIVE("%lurc:when", lurc_when, subr2, (SCM sig, SCM thunk))
{
int ret;
if (STk_procedurep(thunk) == STk_false)
STk_error("bad thunk ~S", thunk);
if (! SIGNALP(sig)) error_bad_signal(sig);
if((ret = lurc_when(&SIGNAL_SIG(sig), enter_context, thunk)) != 0)
lurc_error(ret);
return STk_void;
}
DEFINE_PRIMITIVE("%lurc:watch", lurc_watch, subr2, (SCM sig, SCM thunk))
{
int ret;
SCM *vm;
if (STk_procedurep(thunk) == STk_false)
STk_error("bad thunk ~S", thunk);
if (! SIGNALP(sig)) error_bad_signal(sig);
vm = STk_save_vm();
if((ret = lurc_watch(&SIGNAL_SIG(sig), enter_context, thunk)) != 0){
STk_restore_vm(vm);
lurc_error(ret);
}
STk_restore_vm(vm);
return STk_void;
}
DEFINE_PRIMITIVE("lurc:emit", lurc_emit, subr1, (SCM sig))
{
int ret;
if (! SIGNALP(sig)) error_bad_signal(sig);
if((ret = lurc_signal_emit(&SIGNAL_SIG(sig))) != 0)
lurc_error(ret);
return STk_void;
}
DEFINE_PRIMITIVE("lurc:await", lurc_await, subr1, (SCM sig))
{
int ret;
if (! SIGNALP(sig)) error_bad_signal(sig);
if((ret = lurc_signal_await(&SIGNAL_SIG(sig))) != 0)
lurc_error(ret);
return STk_void;
}
DEFINE_PRIMITIVE("lurc:pause", lurc_pause, subr0, ())
{
int ret;
if((ret = lurc_pause()) != 0)
lurc_error(ret);
return STk_void;
}
//
// Module init
void test(void){
lurc_signal_t sig = lurc_signal("test");
int fail = 0;
printf("entering watch\n");
LURC_WATCH(&sig){
printf("in watch\n");
lurc_signal_emit(&sig);
printf("pausing\n");
lurc_pause();
fail = 1;
}
if(fail)
printf("TEST FAILED\n");
else
printf("test passed\n");
}
MODULE_ENTRY_START("lurc"){
tc_signal = STk_new_user_type();
/* Signal Type declaration */
DEFINE_XTYPE(signal, &xtype_signal);
ADD_PRIMITIVE(lurc_signalp);
ADD_PRIMITIVE(lurc_signal_name);
ADD_PRIMITIVE(lurc_make_signal);
ADD_PRIMITIVE(lurc_when);
ADD_PRIMITIVE(lurc_watch);
ADD_PRIMITIVE(lurc_await);
ADD_PRIMITIVE(lurc_emit);
ADD_PRIMITIVE(lurc_pause);
// test();
}MODULE_ENTRY_END;
(define-module lurc
(load "stklurc.so")
(export
lurc:when