X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Flinux-os.c;h=bcc5e9f62f07018a29d5f70ab7de78fdc239a493;hb=fe962ba01d267b92f638c8f0d19be41054219f04;hp=6724eb127f4057addd7f2094c65e214d193bc005;hpb=4e5668af19abcf84587bf3f7a1c4294cd92c94a7;p=sbcl.git diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c index 6724eb1..bcc5e9f 100644 --- a/src/runtime/linux-os.c +++ b/src/runtime/linux-os.c @@ -82,21 +82,30 @@ static inline int sys_futex (void *futex, int op, int val, struct timespec *rel) } int -futex_wait(int *lock_word, int oldval) +futex_wait(int *lock_word, int oldval, long sec, unsigned long usec) { - int t; - again: - t = sys_futex(lock_word,FUTEX_WAIT,oldval, 0); - - /* Interrupted FUTEX_WAIT calls may return early. - * - * If someone manages to wake the futex while we're spinning - * around it, we will just return with -1 and errno EWOULDBLOCK, - * because the value has changed, so that's ok. */ - if (t != 0 && errno == EINTR) - goto again; + struct timespec timeout; + int t; - return t; + again: + if (sec<0) { + t = sys_futex(lock_word,FUTEX_WAIT,oldval, 0); + } + else { + timeout.tv_sec = sec; + timeout.tv_nsec = usec * 1000; + t = sys_futex(lock_word,FUTEX_WAIT,oldval, &timeout); + } + if (t==0) + return 0; + else if (errno==ETIMEDOUT) + return 1; + else if (errno==EINTR) + /* spurious wakeup from interrupt */ + goto again; + else + /* EWOULDBLOCK and others, need to check the lock */ + return -1; } int @@ -172,7 +181,7 @@ os_init(char *argv[], char *envp[]) } #ifdef LISP_FEATURE_SB_THREAD #if !defined(LISP_FEATURE_SB_LUTEX) && !defined(LISP_FEATURE_SB_PTHREAD_FUTEX) - futex_wait(futex,-1); + futex_wait(futex,-1,-1,0); if(errno==ENOSYS) { lose("This version of SBCL is compiled with threading support, but your kernel\n" "is too old to support this. Please use a more recent kernel or\n" @@ -389,7 +398,7 @@ sigsegv_handler(int signal, siginfo_t *info, void* void_context) #ifdef LISP_FEATURE_GENCGC if (!gencgc_handle_wp_violation(addr)) #else - if (!interrupt_maybe_gc(signal, info, context)) + if (!cheneygc_handle_wp_violation(context, addr)) #endif if (!handle_guard_page_triggered(context, addr)) #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK