diff options
Diffstat (limited to 'libguile/scmsigs.c')
-rw-r--r-- | libguile/scmsigs.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index f404b6a27..a23f151a2 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -159,6 +159,11 @@ signal_delivery_thread (void *data) #if HAVE_PTHREAD_SIGMASK /* not on mingw, see notes above */ sigset_t all_sigs; sigfillset (&all_sigs); + /* On libgc 7.1 and earlier, GC_do_blocking doesn't actually do + anything. So in that case, libgc will want to suspend the signal + delivery thread, so we need to allow it to do so by unmasking the + suspend signal. */ + sigdelset (&all_sigs, GC_get_suspend_signal ()); scm_i_pthread_sigmask (SIG_SETMASK, &all_sigs, NULL); #endif @@ -508,6 +513,23 @@ SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0, #undef FUNC_NAME #endif /* HAVE_ALARM */ +static void +pack_tv (struct timeval *tv, SCM seconds, SCM microseconds) +{ + tv->tv_sec = scm_to_long (seconds); + tv->tv_usec = scm_to_long (microseconds); + + /* Allow usec to be outside the range [0, 999999). */ + tv->tv_sec += tv->tv_usec / (1000 * 1000); + tv->tv_usec %= 1000 * 1000; +} + +static SCM +unpack_tv (const struct timeval *tv) +{ + return scm_cons (scm_from_long (tv->tv_sec), scm_from_long (tv->tv_usec)); +} + #ifdef HAVE_SETITIMER SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0, (SCM which_timer, @@ -537,20 +559,16 @@ SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0, struct itimerval old_timer; c_which_timer = SCM_NUM2INT(1, which_timer); - new_timer.it_interval.tv_sec = SCM_NUM2LONG(2, interval_seconds); - new_timer.it_interval.tv_usec = SCM_NUM2LONG(3, interval_microseconds); - new_timer.it_value.tv_sec = SCM_NUM2LONG(4, value_seconds); - new_timer.it_value.tv_usec = SCM_NUM2LONG(5, value_microseconds); + pack_tv (&new_timer.it_interval, interval_seconds, interval_microseconds); + pack_tv (&new_timer.it_value, value_seconds, value_microseconds); SCM_SYSCALL(rv = setitimer(c_which_timer, &new_timer, &old_timer)); if(rv != 0) SCM_SYSERROR; - return scm_list_2 (scm_cons (scm_from_long (old_timer.it_interval.tv_sec), - scm_from_long (old_timer.it_interval.tv_usec)), - scm_cons (scm_from_long (old_timer.it_value.tv_sec), - scm_from_long (old_timer.it_value.tv_usec))); + return scm_list_2 (unpack_tv (&old_timer.it_interval), + unpack_tv (&old_timer.it_value)); } #undef FUNC_NAME #endif /* HAVE_SETITIMER */ |