/* -*-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
}
}
\f
+int
+DEFUN (UX_channel_descriptor, (channel), Tchannel channel)
+{
+ return (CHANNEL_DESCRIPTOR (channel));
+}
+
int
DEFUN (OS_channel_open_p, (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
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 ()))
? ((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)
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),
/* -*-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
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 */