Commit bd8a8f5e authored by Erick Gallesio's avatar Erick Gallesio

Integration of Stephane Patches

parent e8315019
......@@ -2,22 +2,20 @@
* THINGS TO DO (NEXT RELEASES PLAN)
** Version 0.75 ...
- Always make argv[0] absolute or at least give a way to find it
** Version 0.85 ...
- Terminate canvas implementation
- Add new widgets that exist in 0.51 and have not been ported back
- Add GTk2 support
- Add STk Posix support
- ...
** Version 0.80
- autolad (and syntax-autoload) and modules as in STk?
** Version 0.90
- autoload (and syntax-autoload) and modules as in STk?
- Use packages in all the library to hide functions which
should not be exported. Use a scheme similar to STk, such as
if a user redefines a standard function, it will not break
the library itself.
- Tree widget
- Transcripts
- R5RS Eval
- ...
......@@ -33,8 +31,7 @@ Some things need to be done to be fully R5RS
- Transcripts
** STUFF TO PORT FROM STK
- Implement the virtual ports of STk
** STUFF TO PORT FROM STk
- when-port-readable ...
- ...
......
......@@ -2072,7 +2072,7 @@ fi
# Define the identity of the package.
PACKAGE=stklos
VERSION=0.73
VERSION=0.80
cat >>confdefs.h <<_ACEOF
......
......@@ -2,12 +2,12 @@ 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: 27-Oct-2006 11:17 (eg)
dnl Last file update: 28-Oct-2006 17:22 (eg)
AC_INIT(src/stklos.c)
AC_PREREQ(2.52)
AM_INIT_AUTOMAKE(stklos, 0.73)
AM_INIT_AUTOMAKE(stklos, 0.80)
AM_CONFIG_HEADER(src/stklosconf.h)
AC_PROG_MAKE_SET
......
......@@ -2,7 +2,7 @@
#
# Author: Erick Gallesio [eg@unice.fr]
# Creation date: 11-Apr-2000 10:30 (eg)
# Last file update: 23-May-2005 14:41 (eg)
# Last file update: 28-Oct-2006 16:54 (eg)
mandir = $(prefix)/share/man
man_MANS = stklos.1 stklos-config.1 stklos-compile.1 stklos-genlex.1\
......@@ -52,3 +52,4 @@ $(DOCDB): $(OTHERDB)
clean:
/bin/rm -f $(ALLDB) stklos*.1 *~
distclean: clean
......@@ -18,7 +18,7 @@
#
# Author: Erick Gallesio [eg@unice.fr]
# Creation date: 11-Apr-2000 10:30 (eg)
# Last file update: 23-May-2005 14:41 (eg)
# Last file update: 28-Oct-2006 16:54 (eg)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
......@@ -438,8 +438,6 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
......@@ -520,6 +518,8 @@ $(DOCDB): $(OTHERDB)
#
clean:
/bin/rm -f $(ALLDB) stklos*.1 *~
distclean: clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
......@@ -75,6 +75,10 @@ if DARWIN_THREADS
libgc_la_SOURCES += darwin_stop_world.c
endif
if LURC_THREADS
libgc_la_SOURCES += lurc_support.c
endif
if WIN32_THREADS
libgc_la_SOURCES += win32_threads.c
endif
......
......@@ -120,14 +120,15 @@ DIST_COMMON = $(am__configure_deps) $(am__pkginclude_HEADERS_DIST) \
# ---------------------------------
@PTHREADS_TRUE@am__append_5 = pthread_support.c pthread_stop_world.c
@DARWIN_THREADS_TRUE@am__append_6 = darwin_stop_world.c
@WIN32_THREADS_TRUE@am__append_7 = win32_threads.c
@USE_INTERNAL_LIBATOMIC_OPS_TRUE@am__append_8 = atomic_ops.c
@NEED_ATOMIC_OPS_ASM_TRUE@am__append_9 = atomic_ops_sysdeps.S
@LURC_THREADS_TRUE@am__append_7 = lurc_support.c
@WIN32_THREADS_TRUE@am__append_8 = win32_threads.c
@USE_INTERNAL_LIBATOMIC_OPS_TRUE@am__append_9 = atomic_ops.c
@NEED_ATOMIC_OPS_ASM_TRUE@am__append_10 = atomic_ops_sysdeps.S
# C++ Interface
# -------------
@CPLUSPLUS_TRUE@am__append_10 = libgccpp.la
@CPLUSPLUS_TRUE@am__append_11 = include/gc_cpp.h include/gc_allocator.h
@CPLUSPLUS_TRUE@am__append_11 = libgccpp.la
@CPLUSPLUS_TRUE@am__append_12 = include/gc_cpp.h include/gc_allocator.h
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
......@@ -161,14 +162,15 @@ am__libgc_la_SOURCES_DIST = allchblk.c alloc.c blacklst.c checksums.c \
new_hblk.c obj_map.c os_dep.c pcr_interface.c ptr_chck.c \
real_malloc.c reclaim.c specific.c stubborn.c typd_mlc.c \
backgraph.c thread_local_alloc.c pthread_support.c \
pthread_stop_world.c darwin_stop_world.c win32_threads.c \
atomic_ops.c atomic_ops_sysdeps.S
pthread_stop_world.c darwin_stop_world.c lurc_support.c \
win32_threads.c atomic_ops.c atomic_ops_sysdeps.S
@PTHREADS_TRUE@am__objects_1 = pthread_support.lo \
@PTHREADS_TRUE@ pthread_stop_world.lo
@DARWIN_THREADS_TRUE@am__objects_2 = darwin_stop_world.lo
@WIN32_THREADS_TRUE@am__objects_3 = win32_threads.lo
@USE_INTERNAL_LIBATOMIC_OPS_TRUE@am__objects_4 = atomic_ops.lo
@NEED_ATOMIC_OPS_ASM_TRUE@am__objects_5 = atomic_ops_sysdeps.lo
@LURC_THREADS_TRUE@am__objects_3 = lurc_support.lo
@WIN32_THREADS_TRUE@am__objects_4 = win32_threads.lo
@USE_INTERNAL_LIBATOMIC_OPS_TRUE@am__objects_5 = atomic_ops.lo
@NEED_ATOMIC_OPS_ASM_TRUE@am__objects_6 = atomic_ops_sysdeps.lo
am_libgc_la_OBJECTS = allchblk.lo alloc.lo blacklst.lo checksums.lo \
dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo \
headers.lo malloc.lo mallocx.lo mark.lo mark_rts.lo misc.lo \
......@@ -176,7 +178,7 @@ am_libgc_la_OBJECTS = allchblk.lo alloc.lo blacklst.lo checksums.lo \
real_malloc.lo reclaim.lo specific.lo stubborn.lo typd_mlc.lo \
backgraph.lo thread_local_alloc.lo $(am__objects_1) \
$(am__objects_2) $(am__objects_3) $(am__objects_4) \
$(am__objects_5)
$(am__objects_5) $(am__objects_6)
libgc_la_OBJECTS = $(am_libgc_la_OBJECTS)
@CPLUSPLUS_TRUE@libgccpp_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@CPLUSPLUS_TRUE@ $(am__DEPENDENCIES_1)
......@@ -312,6 +314,7 @@ EXEEXT = @EXEEXT@
EXTRA_TEST_LIBS = @EXTRA_TEST_LIBS@
GC_CFLAGS = @GC_CFLAGS@
GC_VERSION = @GC_VERSION@
GREP = @GREP@
INCLUDES = @INCLUDES@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
......@@ -323,6 +326,8 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LURC_THREADS_FALSE = @LURC_THREADS_FALSE@
LURC_THREADS_TRUE = @LURC_THREADS_TRUE@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
......@@ -354,11 +359,8 @@ USE_LIBDIR_TRUE = @USE_LIBDIR_TRUE@
VERSION = @VERSION@
WIN32_THREADS_FALSE = @WIN32_THREADS_FALSE@
WIN32_THREADS_TRUE = @WIN32_THREADS_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
addlibs = @addlibs@
addobjs = @addobjs@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
......@@ -378,23 +380,30 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
subdirs = @subdirs@
......@@ -451,7 +460,7 @@ EXTRA_DIST = cord/cordbscs.c cord/cordtest.c cord/de.c cord/cordprnt.c \
# C Library
# ---------
lib_LTLIBRARIES = libcord.la libgc.la $(am__append_10)
lib_LTLIBRARIES = libcord.la libgc.la $(am__append_11)
include_HEADERS =
# installed headers
......@@ -462,7 +471,7 @@ pkginclude_HEADERS = include/gc.h include/gc_typed.h \
include/gc_allocator.h include/gc_backptr.h include/gc_gcj.h \
include/leak_detector.h include/gc_amiga_redirects.h \
include/gc_pthread_redirects.h include/gc_config_macros.h \
include/gc_tiny_fl.h $(am__append_11)
include/gc_tiny_fl.h $(am__append_12)
# headers which are not installed
#
......@@ -552,7 +561,8 @@ libgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
specific.c stubborn.c typd_mlc.c backgraph.c \
thread_local_alloc.c $(am__append_5) $(am__append_6) \
$(am__append_7) $(am__append_8) $(am__append_9)
$(am__append_7) $(am__append_8) $(am__append_9) \
$(am__append_10)
# Include THREADDLLIBS here to ensure that the correct versions of
# linuxthread semaphore functions get linked:
......@@ -742,6 +752,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gc_dlopen.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcj_mlc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/headers.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lurc_support.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mallocx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mark.Plo@am__quote@
......
......@@ -5,7 +5,7 @@ set -e
# These version are ok, pre-1.7 is not. Post 1.7 may produce a lot of
# warnings for unrelated projects, so prefer 1.7 for now.
am_version=
for v in 1.7 1.9 1.8; do
for v in 1.8 1.9 1.8; do
if type -p &>/dev/null automake-$v; then
am_version="-$v"
break
......
This diff is collapsed.
......@@ -45,6 +45,23 @@ AC_PROG_INSTALL
GC_CFLAGS=${gc_cflags}
AC_SUBST(GC_CFLAGS)
AC_LANG(C)
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])
])
AC_ARG_ENABLE(threads,
[AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
THREADS=$enableval,
......@@ -68,6 +85,20 @@ AC_ARG_ENABLE(parallel-mark,
AC_ARG_ENABLE(cplusplus,
[AC_HELP_STRING([--enable-cplusplus], [install C++ support])])
if test "$THREADS" = lurc
then
AC_CHECK_HEADER([lurc.h], [have_lurc_h=1], [AC_MSG_ERROR([Missing lurc.h])])
AC_MSG_CHECKING([for LURC GC support])
GC_CHECK_DEFINE([lurc.h], [LURC_ENABLE_GC],
[have_lurc_gc=1; AC_MSG_RESULT(ok)],
[AC_MSG_ERROR([LURC not compiled with GC support])])
AC_MSG_CHECKING([for LURC PThread support])
GC_CHECK_DEFINE([lurc.h], [LURC_ENABLE_PTHREAD],
[AC_MSG_RESULT(yes); THREADS=pthreads; LURC=yes],
[AC_MSG_RESULT(no)])
fi
INCLUDES=-I${srcdir}/include
THREADDLLIBS=
need_atomic_ops_asm=false
......@@ -79,6 +110,12 @@ case "$THREADS" in
posix | pthreads)
THREADS=posix
THREADDLLIBS=-lpthread
# check wether we want LURC support
if test "$LURC" = yes
then
THREADDLLIBS="$THREADLIBS -llurc"
AC_DEFINE(GC_LURC_THREADS)
fi
case "$host" in
x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux*)
AC_DEFINE(GC_LINUX_THREADS)
......@@ -178,6 +215,16 @@ case "$THREADS" in
;;
esac
;;
lurc)
if test "x$have_lurc_h" = x
then AC_MSG_ERROR(Missing lurc.h)
fi
if test "x$have_lurc_gc" = x
then AC_MSG_ERROR(LURC not compiled with GC support)
fi
THREADDLLIBS=-llurc
AC_DEFINE(GC_LURC_THREADS)
;;
win32)
AC_DEFINE(GC_WIN32_THREADS)
dnl Wine getenv may not return NULL for missing entry
......@@ -214,6 +261,7 @@ esac
AC_SUBST(THREADDLLIBS)
AM_CONDITIONAL(THREADS, test x$THREADS != xnone)
AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix)
AM_CONDITIONAL(LURC_THREADS, test x$THREADS = xlurc)
AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue)
AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue)
......@@ -239,7 +287,9 @@ fi
# We never want libdl on darwin. It is a fake libdl that just ends up making
# dyld calls anyway
case "$host" in
*-*-darwin*) ;;
*-*-darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp"
;;
*)
AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
;;
......
......@@ -4,6 +4,10 @@
# if defined(GC_DARWIN_THREADS)
#ifdef GC_LURC_THREADS
# include <lurc.h>
#endif /* GC_LURC_THREADS */
/* From "Inside Mac OS X - Mach-O Runtime Architecture" published by Apple
Page 49:
"The space beneath the stack pointer, where a new stack frame would normally
......@@ -167,6 +171,22 @@ void GC_push_all_stacks() {
#else /* !DARWIN_DONT_PARSE_STACK; Use FindTopOfStack() */
#ifdef GC_LURC_THREADS
static GC_thread lookup_gc_thread(thread_act_t mach_thread){
int i;
GC_thread p;
for (i = 0; i < THREAD_TABLE_SZ; ++i) {
for (p = GC_threads[i]; 0 != p; p = p -> next) {
if(p->stop_info.mach_thread == mach_thread)
return p;
}
}
/* not found ? */
return NULL;
}
#endif /* GC_LURC_THREADS */
void GC_push_all_stacks() {
int i;
task_t my_task;
......@@ -175,6 +195,10 @@ void GC_push_all_stacks() {
ptr_t lo, hi;
thread_act_array_t act_list = 0;
mach_msg_type_number_t listcount = 0;
# ifdef GC_LURC_THREADS
lurc_thread_t lt = NULL;
void *llo,*lhi;
# endif /* GC_LURC_THREADS */
me = mach_thread_self();
if (!GC_thr_initialized) GC_thr_init();
......@@ -184,6 +208,9 @@ void GC_push_all_stacks() {
if(r != KERN_SUCCESS) ABORT("task_threads failed");
for(i = 0; i < listcount; i++) {
thread_act_t thread = act_list[i];
# ifdef GC_LURC_THREADS
GC_thread gct = lookup_gc_thread(thread);
# endif /* GC_LURC_THREADS */
if (thread == me) {
lo = GC_approx_sp();
hi = (ptr_t)FindTopOfStack(0);
......@@ -267,7 +294,27 @@ void GC_push_all_stacks() {
(unsigned long) thread, lo, hi
);
# endif
# ifdef GC_LURC_THREADS
/* check wether the lurc lib wants us to push this now or later */
if (gct != NULL
&& lurc_gc_is_lurc_thread(gct -> id, lo, hi)){
mach_port_deallocate(my_task, thread);
continue;
}
# endif /* GC_LURC_THREADS */
GC_push_all_stack(lo, hi);
# ifdef GC_LURC_THREADS
/* walk all those threads to ask for the roots */
while ((lt = lurc_get_next_thread(lt)) != NULL) {
lurc_gc_get_root(lt, &llo, &lhi);
if(llo != NULL)
GC_push_all_stack(llo, lhi);
}
/* does it have another part ? */
lurc_gc_get_additional_root(&llo, &lhi);
if (llo != NULL)
GC_push_all_stack(llo, lhi);
# endif /* GC_LURC_THREADS */
mach_port_deallocate(my_task, thread);
} /* for(p=GC_threads[i]...) */
vm_deallocate(my_task, (vm_address_t)act_list,
......
......@@ -935,7 +935,8 @@ void * GC_malloc_many(size_t lb);
#define GC_NEXT(p) (*(void * *)(p)) /* Retrieve the next element */
/* in returned list. */
extern void GC_thr_init(void); /* Needed for Solaris/X86 ?? */
#elif defined(GC_LURC_THREADS)
extern void GC_thr_init(void); /* Needed for Solaris/X86 */
#endif /* THREADS && !SRC_M3 */
/* Register a callback to control the scanning of dynamic libraries.
......
......@@ -24,6 +24,9 @@
#if defined(AIX_THREADS)
# define GC_AIX_THREADS
#endif
#if defined(LURC_THREADS)
# define GC_LURC_THREADS
#endif
#if defined(HPUX_THREADS)
# define GC_HPUX_THREADS
#endif
......
......@@ -147,6 +147,13 @@
# endif
# endif /* GC_PTHREADS with linux_threads.c implementation */
# if defined(GC_LURC_THREADS) && !defined(GC_PTHREADS)
# define LOCK()
# define UNLOCK()
# define SET_LOCK_HOLDER()
# define UNSET_LOCK_HOLDER()
# define I_HOLD_LOCK() TRUE
# endif
# else /* !THREADS */
# define LOCK()
......
......@@ -310,7 +310,7 @@ void GC_print_callers(struct callinfo info[NFRAMES]);
PCR_waitForever);
# else
# if defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) \
|| defined(GC_PTHREADS)
|| defined(GC_PTHREADS) || defined(GC_LURC_THREADS)
void GC_stop_world();
void GC_start_world();
# define STOP_WORLD() GC_stop_world()
......
......@@ -2132,7 +2132,7 @@
# if defined(PCR) || defined(SRC_M3) || \
defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
defined(GC_PTHREADS)
defined(GC_PTHREADS) || defined(GC_LURC_THREADS)
# define THREADS
# endif
......
#if defined(GC_LURC_THREADS) && !defined(GC_PTHREADS)
#include "private/gc_priv.h"
#include <lurc.h>
#ifdef LURC_ENABLE_PTHREAD
#error "LURC is compiled with pthread support, but the GC is not. Please use ./configure --enable-threads=lurc-pthreads if you intend to use LURC with PThreads. Or compile LURC without PThread support."
#endif
static int GC_lurc_initialized = 0;
void
GC_push_all_stacks(void){
lurc_thread_t lt = NULL;
void *llo, *lhi;
/* give lurc the main thread's lo and hi */
lurc_gc_setup_stack(GC_approx_sp(), GC_stackbottom);
/* now iterate through all lurcs' threads */
while ((lt = lurc_get_next_thread(lt)) != NULL) {
lurc_gc_get_root(lt, &llo, &lhi);
if(llo != NULL)
GC_push_all_stack(llo, lhi);
}
/* does it have another part ? */
lurc_gc_get_additional_root(&llo, &lhi);
if (llo != NULL)
GC_push_all_stack(llo, lhi);
}
void GC_push_thread_structures(void){}
void GC_stop_world(void){}
void GC_start_world(void){}
void GC_thr_init(void){
if(!GC_lurc_initialized){
GC_lurc_initialized = 1;
lurc_gc_init(GC_enable, GC_disable);
}
}
#endif /* GC_LURC_THREADS && ! GC_PTHREADS */
......@@ -630,11 +630,11 @@ void GC_init_inner()
GC_init_netbsd_elf();
# endif
# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) \
|| defined(GC_WIN32_THREADS)
|| defined(GC_WIN32_THREADS) || defined(GC_LURC_THREADS)
GC_thr_init();
# endif
# if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
|| defined(GC_SOLARIS_THREADS)
|| defined(GC_SOLARIS_THREADS) || defined(GC_LURC_THREADS)
if (GC_stackbottom == 0) {
GC_stackbottom = GC_get_main_stack_base();
# if (defined(LINUX) || defined(HPUX)) && defined(IA64)
......
......@@ -2241,7 +2241,8 @@ void GC_default_push_other_roots(void)
# endif /* PCR */
# if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS)
# if defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
|| defined(GC_LURC_THREADS)
extern void GC_push_all_stacks(void);
......
......@@ -3,6 +3,10 @@
#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && \
!defined(GC_DARWIN_THREADS)
#ifdef GC_LURC_THREADS
# include <lurc.h>
#endif /* GC_LURC_THREADS */
#include <signal.h>
#include <semaphore.h>
#include <errno.h>
......@@ -248,6 +252,10 @@ void GC_push_all_stacks()
/* On IA64, we also need to scan the register backing store. */
IF_IA64(ptr_t bs_lo; ptr_t bs_hi;)
pthread_t me = pthread_self();
# ifdef GC_LURC_THREADS
lurc_thread_t lt = NULL;
void *llo,*lhi;
# endif /* GC_LURC_THREADS */
if (!GC_thr_initialized) GC_thr_init();
# if DEBUG_THREADS
......@@ -281,6 +289,10 @@ void GC_push_all_stacks()
(unsigned)(p -> id), lo, hi);
# endif
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n");
# ifdef GC_LURC_THREADS
/* check wether the lurc lib wants us to push this now or later */
if (lurc_gc_is_lurc_thread(p -> id, lo, hi)) continue;
# endif /* GC_LURC_THREADS */
# ifdef STACK_GROWS_UP
/* We got them backwards! */
GC_push_all_stack(hi, lo);
......@@ -302,6 +314,18 @@ void GC_push_all_stacks()
# endif
}
}
# ifdef GC_LURC_THREADS
/* walk all those threads to ask for the roots */
while ((lt = lurc_get_next_thread(lt)) != NULL) {
lurc_gc_get_root(lt, &llo, &lhi);
if(llo != NULL)
GC_push_all_stack(llo, lhi);
}
/* does it have another part ? */
lurc_gc_get_additional_root(&llo, &lhi);
if (llo != NULL)
GC_push_all_stack(llo, lhi);
# endif /* GC_LURC_THREADS */
if (!found_me && !GC_in_thread_creation)
ABORT("Collecting from unknown thread.");
}
......@@ -330,6 +354,9 @@ int GC_suspend_all()
if (p -> flags & FINISHED) continue;
if (p -> stop_info.last_stop_count == GC_stop_count) continue;
if (p -> thread_blocked) /* Will wait */ continue;
# ifdef GC_LURC_THREADS
if (!lurc_gc_can_stop_thread(p -> id)) continue;
# endif /* GC_LURC_THREADS */
n_live_threads++;
# if DEBUG_THREADS
GC_printf("Sending suspend signal to 0x%x\n",
......
......@@ -102,6 +102,10 @@
typedef unsigned int sem_t;
#endif /* GC_DGUX386_THREADS */
#ifdef GC_LURC_THREADS
# include <lurc.h>
#endif /* GC_LURC_THREADS */
#ifndef __GNUC__
# define __inline__
#endif
......@@ -823,6 +827,12 @@ void GC_thr_init(void)
/* If we are using a parallel marker, actually start helper threads. */
if (GC_parallel) start_mark_threads();
# endif
#ifdef GC_LURC_THREADS
/* initialize the lurc lib so that it calls the proper
gc_pthread_create */
lurc_gc_init(&WRAP_FUNC(pthread_create),
&GC_enable, &GC_disable);
#endif /* GC_LURC_THREADS */
}
......
/*
This file was automatically generated on Fri Oct 27 15:02:12 2006 by make-C-boot
This file was automatically generated on Sat Oct 28 16:29:50 2006 by make-C-boot
This is a dump of the image in file /mnt/users/eg/Projects/STklos/lib/boot.img3
***DO NOT EDIT BY HAND***
*/
......
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@essi.fr]
* Creation date: 2-Feb-2006 21:58 (eg)
* Last file update: 26-Apr-2006 16:20 (eg)
* Last file update: 28-Oct-2006 16:18 (eg)
*/
#include <lurc.h>
......@@ -50,10 +50,15 @@ static void mutex_finalizer(SCM mtx)
{
// any error here is non-forwardable
int err;
if((err = lurc_mutex_destroy(&MUTEX_MYMUTEX(mtx))) != 0)
if(MUTEX_MYMUTEX(mtx) != NULL
&& (err = lurc_mutex_destroy(&MUTEX_MYMUTEX(mtx))) != 0)
STk_panic("Lurc error: ~S", lurc_strerror(err));
if((err = lurc_signal_destroy(&MUTEX_MYSIGNAL(mtx))) != 0)
if(MUTEX_MYSIGNAL(mtx) != NULL
&& (err = lurc_signal_destroy(&MUTEX_MYSIGNAL(mtx))) != 0)
STk_panic("Lurc error: ~S", lurc_strerror(err));
MUTEX_MYMUTEX(mtx) = NULL;
MUTEX_MYSIGNAL(mtx) = NULL;
}
......@@ -238,12 +243,13 @@ static void unlock_watched_await(void *arg){
do{
// skip the first emission if needed
// not that this also works for loop cases
if(CONDV_EMITTED(cv) == lurc_instant())
// note that this also works for loop cases
if(CONDV_EMITTED(cv) == lurc_instant()){
if((err = lurc_pause()) != 0){
ml->raising = 1;
lurc_error(err);
}
}
if((err = lurc_signal_await(&CONDV_MYSIGNAL(cv))) != 0){
ml->raising = 1;
lurc_error(err);
......@@ -275,51 +281,6 @@ static void unlock_finally_destroy(void *arg){
}
}
static void unlock_protected_drop(void *arg){
struct mut_unlock_t* ml = (struct mut_unlock_t*)arg;
SCM mtx = ml->mtx;
int err;
/* Signal to waiting threads */
if((err = lurc_signal_emit(&MUTEX_MYSIGNAL(mtx))) != 0){
ml->raising = 1;
lurc_error(err);
}
if (ml->cv != STk_false) {
if (ml->tm != STk_false) {
struct timeval rel_tv = STk_thread_abstime_to_reltime(REAL_VAL(ml->tm));
ml->timedout = 1;
ml->sig_to = lurc_timeout_signal(NULL, rel_tv);
if(ml->sig_to == NULL)
STk_error("Lurc cannot allocate signal");
// await the signal, but no longer than given timeout
if((err = lurc_protect_with(&unlock_protected_watch, ml,
&unlock_finally_destroy, ml)) != 0){
lurc_signal_destroy(&(ml->sig_to));
ml->raising = 1;
lurc_error(err);
}
if (ml->timedout) ml->res = STk_false;
} else {
if((err = lurc_signal_await(&CONDV_MYSIGNAL(ml->cv))) != 0){
ml->raising = 1;
lurc_error(err);
}
}
}
}
static void unlock_finally_unlock(void *arg){
struct mut_unlock_t* ml = (struct mut_unlock_t*)arg;
SCM mtx = ml->mtx;
int err;
if((err = lurc_mutex_unlock(&MUTEX_MYMUTEX(mtx))) != 0
&& !ml->raising)
lurc_error(err);
}
DEFINE_PRIMITIVE("%mutex-unlock!", mutex_unlock, subr3, (SCM mtx, SCM cv, SCM tm))
{
struct mut_unlock_t ml;
......@@ -344,10 +305,31 @@ DEFINE_PRIMITIVE("%mutex-unlock!", mutex_unlock, subr3, (SCM mtx, SCM cv, SCM tm
ml.tm = tm;
ml.mtx = mtx;
ml.raising = 0;
if((err = lurc_protect_with(&unlock_protected_drop, &ml,
&unlock_finally_unlock, &ml)) != 0){
lurc_mutex_unlock(&MUTEX_MYMUTEX(mtx));
if((err = lurc_mutex_unlock(&MUTEX_MYMUTEX(mtx))) != 0)
lurc_error(err);
/* Signal to waiting threads */
if((err = lurc_signal_emit(&MUTEX_MYSIGNAL(mtx))) != 0)