#define _GNU_SOURCE
+#include "libguile/boehm-gc.h"
#include "libguile/_scm.h"
#if HAVE_UNISTD_H
/*** Thread smob routines */
-static SCM
-thread_mark (SCM obj)
-{
- scm_i_thread *t = SCM_I_THREAD_DATA (obj);
- scm_gc_mark (t->result);
- scm_gc_mark (t->join_queue);
- scm_gc_mark (t->dynwinds);
- scm_gc_mark (t->active_asyncs);
- scm_gc_mark (t->continuation_root);
- return t->dynamic_state;
-}
static int
thread_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
static void
guilify_self_1 (SCM_STACKITEM *base)
{
- scm_i_thread *t = malloc (sizeof (scm_i_thread));
+ scm_i_thread *t = scm_gc_malloc (sizeof (scm_i_thread), "thread");
t->pthread = scm_i_pthread_self ();
t->handle = SCM_BOOL_F;
scm_i_pthread_mutex_init (&t->heap_mutex, NULL);
t->clear_freelists_p = 0;
t->gc_running_p = 0;
+ t->current_mark_stack_ptr = NULL;
+ t->current_mark_stack_limit = NULL;
t->exited = 0;
t->freelist = SCM_EOL;
scm_i_thread *t = SCM_I_CURRENT_THREAD;
SCM_NEWSMOB (t->handle, scm_tc16_thread, t);
- scm_gc_register_collectable_memory (t, sizeof (scm_i_thread), "thread");
+
t->continuation_root = scm_cons (t->handle, SCM_EOL);
t->continuation_base = t->base;
#define SCM_MUTEXP(x) SCM_SMOB_PREDICATE (scm_tc16_mutex, x)
#define SCM_MUTEX_DATA(x) ((fat_mutex *) SCM_SMOB_DATA (x))
-static SCM
-fat_mutex_mark (SCM mx)
-{
- fat_mutex *m = SCM_MUTEX_DATA (mx);
- scm_gc_mark (m->owner);
- return m->waiting;
-}
static size_t
fat_mutex_free (SCM mx)
#define SCM_CONDVARP(x) SCM_SMOB_PREDICATE (scm_tc16_condvar, x)
#define SCM_CONDVAR_DATA(x) ((fat_cond *) SCM_SMOB_DATA (x))
-static SCM
-fat_cond_mark (SCM cv)
-{
- fat_cond *c = SCM_CONDVAR_DATA (cv);
- return c->waiting;
-}
-
static size_t
fat_cond_free (SCM mx)
{
# define SCM_MARK_BACKING_STORE()
#endif
-void
-scm_threads_mark_stacks (void)
-{
- scm_i_thread *t;
- for (t = all_threads; t; t = t->next_thread)
- {
- /* Check that thread has indeed been suspended.
- */
- assert (t->top);
-
- scm_gc_mark (t->handle);
-#if SCM_STACK_GROWS_UP
- scm_mark_locations (t->base, t->top - t->base);
-#else
- scm_mark_locations (t->top, t->base - t->top);
-#endif
- scm_mark_locations ((SCM_STACKITEM *) t->regs,
- ((size_t) sizeof(t->regs)
- / sizeof (SCM_STACKITEM)));
- }
-
- SCM_MARK_BACKING_STORE ();
-}
/*** Select */
scm_init_threads ()
{
scm_tc16_thread = scm_make_smob_type ("thread", sizeof (scm_i_thread));
- scm_set_smob_mark (scm_tc16_thread, thread_mark);
scm_set_smob_print (scm_tc16_thread, thread_print);
- scm_set_smob_free (scm_tc16_thread, thread_free);
+ scm_set_smob_free (scm_tc16_thread, thread_free); /* XXX: Could be removed */
scm_tc16_mutex = scm_make_smob_type ("mutex", sizeof (fat_mutex));
- scm_set_smob_mark (scm_tc16_mutex, fat_mutex_mark);
scm_set_smob_print (scm_tc16_mutex, fat_mutex_print);
scm_set_smob_free (scm_tc16_mutex, fat_mutex_free);
scm_tc16_condvar = scm_make_smob_type ("condition-variable",
sizeof (fat_cond));
- scm_set_smob_mark (scm_tc16_condvar, fat_cond_mark);
scm_set_smob_print (scm_tc16_condvar, fat_cond_print);
scm_set_smob_free (scm_tc16_condvar, fat_cond_free);