From 435afc1e2bb73af410c156e1b983cc478a85d327 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Tue, 9 Jan 2001 15:49:29 +0000 Subject: [PATCH] Changes for Cygwin. --- acconfig.h | 5 ++- configure.in | 6 ++-- scheme/rts/events.scm | 79 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 scheme/rts/events.scm diff --git a/acconfig.h b/acconfig.h index a3e9876..b1e57d6 100644 --- a/acconfig.h +++ b/acconfig.h @@ -38,9 +38,6 @@ /* Define if your sys_errlist is a const definition */ #undef HAVE_CONST_SYS_ERRLIST -/* Include info we know about the system from config.scsh */ -#include "scsh/machine/sysdep.h" - /* Define if you have the nlist() function. This is a not-very-portable way of looking up external symbols. */ #undef HAVE_NLIST @@ -55,6 +52,8 @@ #undef HAVE_HARRIS @BOTTOM@ +/* Include info we know about the system from config.scsh */ +#include "../scsh/machine/sysdep.h" #include "fake/sigact.h" #include "fake/strerror.h" diff --git a/configure.in b/configure.in index fa98e18..b24a9e4 100644 --- a/configure.in +++ b/configure.in @@ -65,7 +65,7 @@ dnl define(S48_USCORE, [dnl AC_MSG_CHECKING([underscore before symbols]) echo 'main() { return 0; } fnord() {}' >conftest.c - if ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c ${LIBS} && + if ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o a.out conftest.c ${LIBS} && nm a.out | grep _fnord >/dev/null; then AC_MSG_RESULT([yes]) AC_DEFINE(USCORE) @@ -154,7 +154,7 @@ AC_DEFUN(SCSH_SIG_NRS, [ AC_DEFINE_UNQUOTED(SIGNR_29, `./scsh_aux 29`, scsh interrupt for signal 29) AC_DEFINE_UNQUOTED(SIGNR_30, `./scsh_aux 30`, scsh interrupt for signal 30) AC_DEFINE_UNQUOTED(SIGNR_31, `./scsh_aux 31`, scsh interrupt for signal 31) - rm -f scsh_aux + rm -f scsh_aux scsh_aux.exe ]) dnl -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- AC_DEFUN(SCSH_LINUX_STATIC_DEBUG, [ @@ -359,7 +359,7 @@ fail AC_MSG_RESULT([no])) S48_USCORE S48_RDYNAMIC - SCSH_TZNAME + AC_STRUCT_TIMEZONE SCSH_GMTOFF SCSH_CONST_SYS_ERRLIST CFLAGS1=${CFLAGS} diff --git a/scheme/rts/events.scm b/scheme/rts/events.scm new file mode 100644 index 0000000..51b0a67 --- /dev/null +++ b/scheme/rts/events.scm @@ -0,0 +1,79 @@ +; Copyright (c) 1999-2001 by Martin Gasbichler. See file COPYING. + +;;; Functional event system. +;;; System by Olin Shivers, implementation by Martin Gasbichler + +(define-record-type event :event + (really-make-event type next) + event? + (type event-type set-event-type!) + (next next-event set-next-event!)) + +(define (make-event type) + (really-make-event type #f)) + +(define empty-event (make-event #f)) + +(define *most-recent-event* empty-event) + +(define (most-recent-event) *most-recent-event*) + +(define event-thread-queue #f) + +;Wait for an event of a certain type. +(define (rts-wait-interrupt set pre-event type-in-set?) + (with-interrupts-inhibited + (lambda () + (let lp ((event (next-event pre-event))) + (if event + (if (type-in-set? (event-type event) set) + event + (lp (next-event event))) + (begin (enqueue-thread! event-thread-queue (current-thread)) + (block) + (lp (next-event pre-event)))))))) + +; same as above, but don't block +(define (rts-maybe-wait-interrupt set pre-event type-in-set?) + (let ((event (next-event pre-event))) + (if event + (if (type-in-set? (event-type event) set) + event + (rts-maybe-wait-interrupt set (next-event event) type-in-set?)) + #f))) + + +;Called when the interrupt actually happened. +;;; TODO w-i-i is problaly not necessary since they're off already +(define (register-interrupt type) + (let ((waiters (with-interrupts-inhibited + (lambda () + (set-next-event! *most-recent-event* (make-event type)) + (set! *most-recent-event* (next-event *most-recent-event*)) + (do ((waiters '() (cons (dequeue-thread! event-thread-queue) + waiters))) + ((thread-queue-empty? event-thread-queue) + waiters)))))) + (for-each make-ready waiters))) + +;;; has to be called with interrupts disabled +(define (waiting-for-os-event?) + (not (thread-queue-empty? event-thread-queue))) + +(define (initialize-events!) + (set! event-thread-queue (make-thread-queue)) + (set-interrupt-handler! (enum interrupt os-signal) + (lambda (type arg enabled-interrupts) + ; type is already set in the unix signal handler + (register-interrupt type))) + (set-interrupt-handler! (enum interrupt keyboard) + (lambda (enabled-interrupts) + (register-interrupt (enum interrupt keyboard)))) +; (call-after-gc! (lambda () (register-interrupt (enum interrupt post-gc)))) +) +;;; the vm uses the timer for the scheduler +(define (schedule-timer-interrupt! msec) + (spawn (lambda () + (sleep msec) + (register-interrupt (enum interrupt alarm))))) +