AC_CHECK_FUNCS([poll pollts ppoll posix_madvise posix_openpt prealloc])
AC_CHECK_FUNCS([rename rmdir])
AC_CHECK_FUNCS([pselect select setitimer setpgrp setpgrp2 shmat sigaction])
-AC_CHECK_FUNCS([sighold socket statfs strchr strerror strstr strtol])
+AC_CHECK_FUNCS([sighold sigsuspend socket statfs strchr strerror strstr strtol])
AC_CHECK_FUNCS([strtoul symlink sync_file_range sysconf])
AC_CHECK_FUNCS([times truncate])
AC_CHECK_FUNCS([uname utime])
}
}
+int
+OS_pause (void)
+{
+ /* Wait-for-io must spin. */
+ return
+ ((OS_process_any_status_change ())
+ ? SELECT_PROCESS_STATUS_CHANGE
+ : SELECT_INTERRUPT);
+}
+
static int
wait_on_multiple_objects (struct select_registry_s * r)
{
interruptp = 1;
}
}
+
+int
+OS_pause (void)
+{
+ /* Wait-for-io must spin. */
+ return
+ ((OS_process_any_status_change ())
+ ? SELECT_PROCESS_STATUS_CHANGE
+ : SELECT_INTERRUPT);
+}
(select_registry_t registry, int blockp);
extern int OS_test_select_descriptor
(int fd, int blockp, unsigned int mode);
+extern int OS_pause (void);
#endif /* SCM_OSIO_H */
error_bad_range_arg (3);
if ((VECTOR_LENGTH (vmode)) < rl)
error_bad_range_arg (4);
- result = (OS_test_select_registry (r, blockp));
+ result = ((rl == 0)
+ ? (blockp ? (OS_pause ()) : SELECT_INTERRUPT)
+ : (OS_test_select_registry (r, blockp)));
if (result > 0)
{
unsigned int i = 0;
}
#endif /* not HAVE_POLL */
+
+int
+OS_pause (void)
+{
+#ifdef HAVE_SIGSUSPEND
+ sigset_t old, new;
+
+ UX_sigfillset (&new);
+ UX_sigprocmask (SIG_SETMASK, &new, &old);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ if (pending_interrupts_p ())
+ return (SELECT_INTERRUPT);
+ UX_sigsuspend (&old);
+ UX_sigprocmask (SIG_SETMASK, &old, NULL);
+ if (OS_process_any_status_change ())
+ return (SELECT_PROCESS_STATUS_CHANGE);
+ return (SELECT_INTERRUPT);
+#else
+ /* Wait-for-io must spin. */
+ return
+ ((OS_process_any_status_change ())
+ ? SELECT_PROCESS_STATUS_CHANGE
+ : SELECT_INTERRUPT);
+#endif
+}
condition
(within-continuation k thunk))
thunk))))))))
- (if (not io-registrations)
- (begin
- ;; Busy-waiting here is a bad idea -- should implement a
- ;; primitive to block the Scheme process while waiting for a
- ;; signal.
- (catch-errors
- (lambda ()
- (set-interrupt-enables! interrupt-mask/all)
- (do () (#f)))))
- (let ((result
- (catch-errors
- (lambda ()
- (set-interrupt-enables! interrupt-mask/all)
- (test-select-registry io-registry #t)))))
- (set-interrupt-enables! interrupt-mask/gc-ok)
- (signal-select-result result)
- (let ((thread first-running-thread))
- (if thread
- (if (thread/continuation thread)
- (run-thread thread)
- (%maybe-toggle-thread-timer))
- (wait-for-io)))))))
+ (let ((result
+ (catch-errors
+ (lambda ()
+ (set-interrupt-enables! interrupt-mask/all)
+ (test-select-registry io-registry #t)))))
+ (set-interrupt-enables! interrupt-mask/gc-ok)
+ (signal-select-result result)
+ (let ((thread first-running-thread))
+ (if thread
+ (if (thread/continuation thread)
+ (run-thread thread)
+ (%maybe-toggle-thread-timer))
+ (wait-for-io))))))
\f
(define (signal-select-result result)
(cond ((vector? result)