/* -*-C-*-
-$Id: ux.c,v 1.36 2008/05/04 07:13:37 cph Exp $
+$Id: ux.c,v 1.37 2009/04/15 13:00:19 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
deliver_pending_interrupts ();
}
+void
+UX_prim_check_fd_errno (enum syscall_names name)
+{
+ static bool out_of_files_p = false;
+ switch (errno)
+ {
+ case EINTR:
+ deliver_pending_interrupts ();
+ break;
+
+ case EMFILE:
+ case ENFILE:
+ if (!out_of_files_p)
+ {
+ out_of_files_p = true;
+ REQUEST_GC (0);
+ deliver_pending_interrupts ();
+ }
+ /* Fall through */
+
+ default:
+ error_system_call (errno, name);
+ }
+}
+\f
#ifdef HAVE_TERMIOS_H
int
/* -*-C-*-
-$Id: ux.h,v 1.90 2009/03/21 07:09:09 riastradh Exp $
+$Id: ux.h,v 1.91 2009/04/15 13:00:24 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
#endif /* not _POSIX_VERSION */
\f
extern void UX_prim_check_errno (enum syscall_names name);
-
-#define STD_VOID_SYSTEM_CALL(name, expression) \
-{ \
- while ((expression) < 0) \
- { \
- if (errno != EINTR) \
- error_system_call (errno, (name)); \
- deliver_pending_interrupts (); \
- } \
-}
-
-#define STD_UINT_SYSTEM_CALL(name, result, expression) \
-{ \
- while (((result) = (expression)) < 0) \
- { \
- if (errno != EINTR) \
- error_system_call (errno, (name)); \
- deliver_pending_interrupts (); \
- } \
-}
-
-#define STD_PTR_SYSTEM_CALL(name, result, expression) \
-{ \
- while (((result) = (expression)) == 0) \
- { \
- if (errno != EINTR) \
- error_system_call (errno, (name)); \
- deliver_pending_interrupts (); \
- } \
-}
+extern void UX_prim_check_fd_errno (enum syscall_names name);
+
+#define STD_VOID_SYSTEM_CALL(name, expression) \
+ do { \
+ while ((expression) < 0) \
+ UX_prim_check_errno (name); \
+ } while (0)
+
+#define STD_UINT_SYSTEM_CALL(name, result, expression) \
+ do { \
+ while (((result) = (expression)) < 0) \
+ UX_prim_check_errno (name); \
+ } while (0)
+
+#define STD_PTR_SYSTEM_CALL(name, result, expression) \
+ do { \
+ while (((result) = (expression)) == 0) \
+ UX_prim_check_errno (name); \
+ } while (0)
+
+#define STD_FD_SYSTEM_CALL(name, result, expression) \
+ do { \
+ while (((result) = (expression)) < 0) \
+ UX_prim_check_fd_errno (name); \
+ } while (0)
#endif /* SCM_UX_H */
/* -*-C-*-
-$Id: uxfile.c,v 1.19 2009/04/15 03:02:48 riastradh Exp $
+$Id: uxfile.c,v 1.20 2009/04/15 13:00:29 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
terminal_open (channel);
return (channel);
}
-\f
+
static Tchannel
open_file (const char * filename, int oflag)
{
- static bool out_of_files_p = false;
int fd;
- while ((fd = (UX_open (filename, oflag, MODE_REG))) < 0)
- {
- switch (errno)
- {
- case EINTR:
- deliver_pending_interrupts ();
- break;
-
- case EMFILE:
- case ENFILE:
- if (!out_of_files_p)
- {
- out_of_files_p = true;
- REQUEST_GC (0);
- signal_interrupt_from_primitive ();
- }
- /* Fall through. */
-
- default:
- error_system_call (errno, syscall_open);
- }
- }
- out_of_files_p = false;
+ STD_FD_SYSTEM_CALL (syscall_open, fd, (UX_open (filename, oflag, MODE_REG)));
#ifdef SLAVE_PTY_P
if ((SLAVE_PTY_P (filename)) && (!UX_setup_slave_pty (fd)))
{
/* -*-C-*-
-$Id: uxio.c,v 1.63 2009/03/21 21:23:22 riastradh Exp $
+$Id: uxio.c,v 1.64 2009/04/15 13:00:32 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
{
int pv [2];
transaction_begin ();
- STD_VOID_SYSTEM_CALL (syscall_pipe, (UX_pipe (pv)));
+ while ((UX_pipe (pv)) < 0)
+ UX_prim_check_fd_errno (syscall_pipe);
MAKE_CHANNEL ((pv[0]), channel_type_unix_pipe, (*readerp) =);
OS_channel_close_on_abort (*readerp);
MAKE_CHANNEL ((pv[1]), channel_type_unix_pipe, (*writerp) =);
/* -*-C-*-
-$Id: uxsock.c,v 1.37 2008/01/30 20:02:22 cph Exp $
+$Id: uxsock.c,v 1.38 2009/04/15 13:00:32 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
Tchannel channel;
transaction_begin ();
- STD_UINT_SYSTEM_CALL
+ STD_FD_SYSTEM_CALL
(syscall_socket, s, (UX_socket (AF_INET, SOCK_STREAM, 0)));
MAKE_CHANNEL (s, channel_type_tcp_stream_socket, channel =);
OS_channel_close_on_abort (channel);
Tchannel channel;
transaction_begin ();
- STD_UINT_SYSTEM_CALL
+ STD_FD_SYSTEM_CALL
(syscall_socket, s, (UX_socket (AF_UNIX, SOCK_STREAM, 0)));
MAKE_CHANNEL (s, channel_type_unix_stream_socket, channel =);
OS_channel_close_on_abort (channel);
OS_create_tcp_server_socket (void)
{
int s;
- STD_UINT_SYSTEM_CALL
+ STD_FD_SYSTEM_CALL
(syscall_socket, s, (UX_socket (AF_INET, SOCK_STREAM, 0)));
MAKE_CHANNEL (s, channel_type_tcp_server_socket, return);
}