diff options
Diffstat (limited to 'libguile/threads.c')
-rw-r--r-- | libguile/threads.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/libguile/threads.c b/libguile/threads.c index b009e7169..2787ed4bd 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -61,6 +61,9 @@ # define pipe(fd) _pipe (fd, 256, O_BINARY) #endif /* __MINGW32__ */ +#include <full-read.h> + + static void to_timespec (SCM t, scm_t_timespec *waittime) { @@ -481,8 +484,13 @@ guilify_self_1 (SCM_STACKITEM *base) t->sleep_mutex = NULL; t->sleep_object = SCM_BOOL_F; t->sleep_fd = -1; - /* XXX - check for errors. */ - pipe (t->sleep_pipe); + + if (pipe (t->sleep_pipe) != 0) + /* FIXME: Error conditions during the initialization phase are handled + gracelessly since public functions such as `scm_init_guile ()' + currently have type `void'. */ + abort (); + scm_i_pthread_mutex_init (&t->heap_mutex, NULL); scm_i_pthread_mutex_init (&t->admin_mutex, NULL); t->clear_freelists_p = 0; @@ -700,9 +708,18 @@ scm_i_init_thread_for_guile (SCM_STACKITEM *base, SCM parent) /* This thread is already guilified but not in guile mode, just resume it. - XXX - base might be lower than when this thread was first - guilified. - */ + A user call to scm_with_guile() will lead us to here. This could + happen from anywhere on the stack, and in particular lower on the + stack than when it was when this thread was first guilified. Thus, + `base' must be updated. */ +#if SCM_STACK_GROWS_UP + if (base < t->base) + t->base = base; +#else + if (base > t->base) + t->base = base; +#endif + scm_enter_guile ((scm_t_guile_ticket) t); return 1; } @@ -1723,7 +1740,7 @@ scm_threads_mark_stacks (void) #else scm_mark_locations (t->top, t->base - t->top); #endif - scm_mark_locations ((SCM_STACKITEM *) &t->regs, + scm_mark_locations ((void *) &t->regs, ((size_t) sizeof(t->regs) / sizeof (SCM_STACKITEM))); } @@ -1769,7 +1786,8 @@ scm_std_select (int nfds, if (res > 0 && FD_ISSET (wakeup_fd, readfds)) { char dummy; - read (wakeup_fd, &dummy, 1); + full_read (wakeup_fd, &dummy, 1); + FD_CLR (wakeup_fd, readfds); res -= 1; if (res == 0) |