Implement new interface to `select' system call, which allows
authorChris Hanson <org/chris-hanson/cph>
Wed, 10 Mar 1993 17:57:08 +0000 (17:57 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 10 Mar 1993 17:57:08 +0000 (17:57 +0000)
construction of "registries" of file descriptors, which can then be
passed in as arguments.

v7/src/microcode/unxutl/ymkfile
v7/src/microcode/uxio.c
v7/src/microcode/uxselect.h
v7/src/microcode/version.h
v7/src/microcode/x11base.c
v8/src/microcode/version.h

index 2ee2c45f8747b8090d51ff3ff95555aeeaee614a..62c537e81339f80447fdd02842c749d05893d9d4 100644 (file)
@@ -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
index 2e163e32d0795e1c51d3513235213904a7ee27fb..a65dc127f7ea1d142bc83ca367a24ba284515008 100644 (file)
@@ -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)
     }
 }
 \f
+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 */
 \f
-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;
-    }
-}
-\f
 #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)));
+}
+\f
 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
 }
+\f
+/* 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),
index 121a8cbfb53a72e703eb9fadb806c73873b38e9b..679e55bc6b497e184250c4766621715bdca59d5b 100644 (file)
@@ -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 */
index 073ff34ac0796353fb07724eb7746e20ef60b40c..a1c595abdb4a37590b5ff8b46927e41182369278 100644 (file)
@@ -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
index b807021f8410c59bb2cf19e28c4ffcc85123cbd3..7282c4dde34fa855403f980ad94b3591f937a712 100644 (file)
@@ -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)
 \f
 /* 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);
index 073ff34ac0796353fb07724eb7746e20ef60b40c..a1c595abdb4a37590b5ff8b46927e41182369278 100644 (file)
@@ -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