From dda8a0b016ce7b12c0b12681cf4c0dbf1cfdac6f Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 10 Mar 1993 17:57:08 +0000 Subject: [PATCH] Implement new interface to `select' system call, which allows construction of "registries" of file descriptors, which can then be passed in as arguments. --- v7/src/microcode/unxutl/ymkfile | 7 +- v7/src/microcode/uxio.c | 151 ++++++++++++++++++++++---------- v7/src/microcode/uxselect.h | 12 ++- v7/src/microcode/version.h | 4 +- v7/src/microcode/x11base.c | 9 +- v8/src/microcode/version.h | 4 +- 6 files changed, 133 insertions(+), 54 deletions(-) diff --git a/v7/src/microcode/unxutl/ymkfile b/v7/src/microcode/unxutl/ymkfile index 2ee2c45f8..62c537e81 100644 --- a/v7/src/microcode/unxutl/ymkfile +++ b/v7/src/microcode/unxutl/ymkfile @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ymkfile,v 1.62 1993/02/15 03:40:39 gjr Exp $ +$Id: ymkfile,v 1.63 1993/03/10 17:57:08 cph Exp $ Copyright (c) 1989-1993 Massachusetts Institute of Technology @@ -423,6 +423,7 @@ prosterm.c \ prostty.c \ pruxenv.c \ pruxfs.c \ +pruxio.c \ pruxsock.c HEAD_FILES = scheme.touch prims.h zones.h locks.h bignum.h \ @@ -504,6 +505,7 @@ prosterm.o \ prostty.o \ pruxenv.o \ pruxfs.o \ +pruxio.o \ pruxsock.o STD_GC_OBJECTS = \ @@ -719,7 +721,7 @@ error.o ptrvec.o transact.o : ansidecl.h dstack.h wind.o : ansidecl.h dstack.h obstack.h obstack.o : obstack.h -$(UNIX_OBJECTS) pruxenv.o pruxfs.o pruxsock.o : oscond.h ansidecl.h \ +$(UNIX_OBJECTS) pruxenv.o pruxfs.o pruxio.o pruxsock.o : oscond.h ansidecl.h \ posixtype.h intext.h dstack.h os.h osscheme.h ux.h uxctty.o : osctty.h ossig.h uxenv.o : osenv.h @@ -735,6 +737,7 @@ uxtrap.o : scheme.touch uxtrap.h uxutil.h option.h $(GC_HEAD_FILES) uxtty.o : ostty.h osenv.h osio.h uxio.h osterm.h uxterm.h uxutil.o : uxutil.h pruxfs.o : osfs.h +pruxio.o : osio.h uxselect.h pruxsock.o : osio.h uxsock.h $(OS_PRIM_OBJECTS) : scheme.touch prims.h posixtype.h os.h diff --git a/v7/src/microcode/uxio.c b/v7/src/microcode/uxio.c index 2e163e32d..a65dc127f 100644 --- a/v7/src/microcode/uxio.c +++ b/v7/src/microcode/uxio.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.22 1992/06/11 12:50:02 jinx Exp $ +$Id: uxio.c,v 1.23 1993/03/10 17:55:43 cph Exp $ -Copyright (c) 1990-1992 Massachusetts Institute of Technology +Copyright (c) 1990-93 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -115,6 +115,12 @@ DEFUN_VOID (channel_allocate) } } +int +DEFUN (UX_channel_descriptor, (channel), Tchannel channel) +{ + return (CHANNEL_DESCRIPTOR (channel)); +} + int DEFUN (OS_channel_open_p, (channel), Tchannel channel) { @@ -360,38 +366,8 @@ DEFUN (OS_channel_blocking, (channel), Tchannel channel) #endif /* FCNTL_NONBLOCK */ -int -DEFUN (OS_channel_registered_p, (channel), Tchannel channel) -{ - return (CHANNEL_REGISTERED (channel)); -} - -void -DEFUN (OS_channel_register, (channel), Tchannel channel) -{ -#ifdef HAVE_SELECT - if (! (CHANNEL_REGISTERED (channel))) - { - FD_SET ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors)); - OS_channels_registered += 1; - (CHANNEL_REGISTERED (channel)) = 1; - } -#else - error_unimplemented_primitive (); -#endif -} +/* select(2) system call */ -void -DEFUN (OS_channel_unregister, (channel), Tchannel channel) -{ - if (CHANNEL_REGISTERED (channel)) - { - FD_CLR ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors)); - OS_channels_registered -= 1; - (CHANNEL_REGISTERED (channel)) = 0; - } -} - #if defined(_HPUX) && (_HPUX_VERSION >= 80) #define SELECT_DECLARED #endif @@ -408,19 +384,55 @@ extern int EXFUN (UX_select, CONST int UX_have_select_p = 0; #endif /* not HAVE_SELECT */ +unsigned int +DEFUN_VOID (UX_select_registry_size) +{ + return (sizeof (SELECT_TYPE)); +} + +unsigned int +DEFUN_VOID (UX_select_registry_lub) +{ + return (FD_SETSIZE); +} + +void +DEFUN (UX_select_registry_clear_all, (fds), PTR fds) +{ + FD_ZERO ((SELECT_TYPE *) fds); +} + +void +DEFUN (UX_select_registry_set, (fds, fd), PTR fds AND unsigned int fd) +{ + FD_SET (fd, ((SELECT_TYPE *) fds)); +} + +void +DEFUN (UX_select_registry_clear, (fds, fd), PTR fds AND unsigned int fd) +{ + FD_CLR (fd, ((SELECT_TYPE *) fds)); +} + +int +DEFUN (UX_select_registry_is_set, (fds, fd), PTR fds AND unsigned int fd) +{ + return (FD_ISSET (fd, ((SELECT_TYPE *) fds))); +} + enum select_input -DEFUN (UX_select_input, (fd, blockp), int fd AND int blockp) +DEFUN (UX_select_registry_test, (input_fds, output_fds, blockp), + PTR input_fds AND + PTR output_fds AND + int blockp) { #ifdef HAVE_SELECT - int status_change_p; - int nfds; - SELECT_TYPE readable; - - readable = input_descriptors; - FD_SET (fd, (&readable)); while (1) { - status_change_p = 0; + SELECT_TYPE readable = (* ((SELECT_TYPE *) input_fds)); + int status_change_p = 0; + int nfds; + INTERRUPTABLE_EXTENT (nfds, ((status_change_p = (UX_process_any_status_change ())) @@ -433,10 +445,10 @@ DEFUN (UX_select_input, (fd, blockp), int fd AND int blockp) ? ((struct timeval *) 0) : (&zero_timeout)))))); if (nfds > 0) - return - ((FD_ISSET (fd, (&readable))) - ? select_input_argument - : select_input_other); + { + (* ((SELECT_TYPE *) output_fds)) = readable; + return (select_input_argument); + } else if (nfds == 0) { if (!blockp) @@ -454,6 +466,55 @@ DEFUN (UX_select_input, (fd, blockp), int fd AND int blockp) return (select_input_argument); #endif } + +/* Old Global Registry Mechanism */ + +int +DEFUN (OS_channel_registered_p, (channel), Tchannel channel) +{ + return (CHANNEL_REGISTERED (channel)); +} + +void +DEFUN (OS_channel_register, (channel), Tchannel channel) +{ +#ifdef HAVE_SELECT + if (! (CHANNEL_REGISTERED (channel))) + { + FD_SET ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors)); + OS_channels_registered += 1; + (CHANNEL_REGISTERED (channel)) = 1; + } +#else + error_unimplemented_primitive (); +#endif +} + +void +DEFUN (OS_channel_unregister, (channel), Tchannel channel) +{ + if (CHANNEL_REGISTERED (channel)) + { + FD_CLR ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors)); + OS_channels_registered -= 1; + (CHANNEL_REGISTERED (channel)) = 0; + } +} + +enum select_input +DEFUN (UX_select_input, (fd, blockp), int fd AND int blockp) +{ + SELECT_TYPE readable = input_descriptors; + FD_SET (fd, (&readable)); + { + enum select_input s = + (UX_select_registry_test ((&readable), (&readable), blockp)); + return + (((s == select_input_argument) && (! (FD_ISSET (fd, (&readable))))) + ? select_input_other + : s); + } +} long DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes), diff --git a/v7/src/microcode/uxselect.h b/v7/src/microcode/uxselect.h index 121a8cbfb..679e55bc6 100644 --- a/v7/src/microcode/uxselect.h +++ b/v7/src/microcode/uxselect.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxselect.h,v 1.2 1992/02/04 04:37:11 cph Exp $ +$Id: uxselect.h,v 1.3 1993/03/10 17:55:54 cph Exp $ -Copyright (c) 1991-92 Massachusetts Institute of Technology +Copyright (c) 1991-93 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -46,5 +46,13 @@ enum select_input extern CONST int UX_have_select_p; extern enum select_input EXFUN (UX_select_input, (int fd, int blockp)); +extern unsigned int EXFUN (UX_select_registry_size, (void)); +extern unsigned int EXFUN (UX_select_registry_lub, (void)); +extern void EXFUN (UX_select_registry_clear_all, (PTR fds)); +extern void EXFUN (UX_select_registry_set, (PTR fds, unsigned int fd)); +extern void EXFUN (UX_select_registry_clear, (PTR fds, unsigned int fd)); +extern int EXFUN (UX_select_registry_is_set, (PTR fds, unsigned int fd)); +extern enum select_input EXFUN + (UX_select_registry_test, (PTR input_fds, PTR output_fds, int blockp)); #endif /* SCM_UXSELECT_H */ diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 073ff34ac..a1c595abd 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.128 1993/02/19 17:49:44 cph Exp $ +$Id: version.h,v 11.129 1993/03/10 17:56:45 cph Exp $ Copyright (c) 1988-1993 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 128 +#define SUBVERSION 129 #endif diff --git a/v7/src/microcode/x11base.c b/v7/src/microcode/x11base.c index b807021f8..7282c4dde 100644 --- a/v7/src/microcode/x11base.c +++ b/v7/src/microcode/x11base.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: x11base.c,v 1.46 1993/02/02 22:14:51 nick Exp $ +$Id: x11base.c,v 1.47 1993/03/10 17:56:24 cph Exp $ Copyright (c) 1989-93 Massachusetts Institute of Technology @@ -1276,6 +1276,13 @@ DEFINE_PRIMITIVE ("X-CLOSE-WINDOW", Prim_x_close_window, 1, 1, 0) /* Event Processing Primitives */ +DEFINE_PRIMITIVE ("X-DISPLAY-DESCRIPTOR", Prim_x_display_descriptor, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + PRIMITIVE_RETURN + (long_to_integer (ConnectionNumber (XD_DISPLAY (x_display_arg (1))))); +} + DEFINE_PRIMITIVE ("X-DISPLAY-PROCESS-EVENTS", Prim_x_display_process_events, 2, 2, 0) { PRIMITIVE_HEADER (2); diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 073ff34ac..a1c595abd 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: version.h,v 11.128 1993/02/19 17:49:44 cph Exp $ +$Id: version.h,v 11.129 1993/03/10 17:56:45 cph Exp $ Copyright (c) 1988-1993 Massachusetts Institute of Technology @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 128 +#define SUBVERSION 129 #endif -- 2.25.1