(Faref): Delete codes for a composite character..
[bpt/emacs.git] / src / sysdep.c
index 90a0ebd..bce69a4 100644 (file)
@@ -1,5 +1,5 @@
 /* Interfaces to system-dependent kernel and library entries.
 /* Interfaces to system-dependent kernel and library entries.
-   Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc.
+   Copyright (C) 1985, 86,87,88,93,94,95, 1999 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 
 This file is part of GNU Emacs.
 
@@ -19,13 +19,10 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 
 Boston, MA 02111-1307, USA.  */
 
 
+#include <config.h>
 #include <signal.h>
 #include <setjmp.h>
 
 #include <signal.h>
 #include <setjmp.h>
 
-#include <config.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
 #include "lisp.h"
 #include "blockinput.h"
 #undef NULL
 #include "lisp.h"
 #include "blockinput.h"
 #undef NULL
@@ -50,18 +47,6 @@ Lisp_Object Vx_bitmap_file_path;
 
 #define min(x,y) ((x) > (y) ? (y) : (x))
 
 
 #define min(x,y) ((x) > (y) ? (y) : (x))
 
-/* In this file, open, read and write refer to the system calls,
-   not our sugared interfaces  sys_open, sys_read and sys_write.
-   Contrariwise, for systems where we use the system calls directly,
-   define sys_read, etc. here as aliases for them.  */
-#ifndef read
-#define sys_read read
-#define sys_write write
-#endif /* `read' is not a macro */
-
-#undef read
-#undef write
-
 #ifdef WINDOWSNT
 #define read _read
 #define write _write
 #ifdef WINDOWSNT
 #define read _read
 #define write _write
@@ -69,18 +54,6 @@ Lisp_Object Vx_bitmap_file_path;
 extern int errno;
 #endif /* not WINDOWSNT */
 
 extern int errno;
 #endif /* not WINDOWSNT */
 
-#ifndef close
-#define sys_close close
-#else 
-#undef close
-#endif
-
-#ifndef open
-#define sys_open open
-#else /* `open' is a macro */
-#undef open
-#endif /* `open' is a macro */
-
 /* Does anyone other than VMS need this? */
 #ifndef fwrite
 #define sys_fwrite fwrite
 /* Does anyone other than VMS need this? */
 #ifndef fwrite
 #define sys_fwrite fwrite
@@ -2710,25 +2683,6 @@ read_input_waiting ()
 #endif /* not MSDOS */
 \f
 #ifdef BSD4_1
 #endif /* not MSDOS */
 \f
 #ifdef BSD4_1
-/*
- * Partially emulate 4.2 open call.
- * open is defined as this in 4.1.
- *
- * - added by Michael Bloom @ Citicorp/TTI
- *
- */
-
-int
-sys_open (path, oflag, mode)
-     char *path;
-     int oflag, mode;
-{
-  if (oflag & O_CREAT) 
-    return creat (path, mode);
-  else
-    return open (path, oflag);
-}
-
 void
 init_sigio (fd)
      int fd;
 void
 init_sigio (fd)
      int fd;
@@ -2817,13 +2771,6 @@ sigbit (i)
 
 sigset_t empty_mask, full_mask;
 
 
 sigset_t empty_mask, full_mask;
 
-void
-init_signals ()
-{
-  sigemptyset (&empty_mask);
-  sigfillset (&full_mask);
-}
-
 signal_handler_t
 sys_signal (int signal_number, signal_handler_t action)
 {
 signal_handler_t
 sys_signal (int signal_number, signal_handler_t action)
 {
@@ -2886,6 +2833,185 @@ sys_sigsetmask (sigset_t new_mask)
 
 #endif /* POSIX_SIGNALS */
 \f
 
 #endif /* POSIX_SIGNALS */
 \f
+#if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED
+static char *my_sys_siglist[NSIG];
+# ifdef sys_siglist
+#  undef sys_siglist
+# endif
+# define sys_siglist my_sys_siglist
+#endif
+
+void
+init_signals ()
+{
+#ifdef POSIX_SIGNALS
+  sigemptyset (&empty_mask);
+  sigfillset (&full_mask);
+#endif
+
+#if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED
+  if (! initialized)
+    {
+# ifdef SIGABRT
+      sys_siglist[SIGABRT] = "Aborted";
+# endif
+# ifdef SIGAIO
+      sys_siglist[SIGAIO] = "LAN I/O interrupt";
+# endif
+# ifdef SIGALRM
+      sys_siglist[SIGALRM] = "Alarm clock";
+# endif
+# ifdef SIGBUS
+      sys_siglist[SIGBUS] = "Bus error";
+# endif
+# ifdef SIGCLD
+      sys_siglist[SIGCLD] = "Child status changed";
+# endif
+# ifdef SIGCHLD
+      sys_siglist[SIGCHLD] = "Child status changed";
+# endif
+# ifdef SIGCONT
+      sys_siglist[SIGCONT] = "Continued";
+# endif
+# ifdef SIGDANGER
+      sys_siglist[SIGDANGER] = "Swap space dangerously low";
+# endif
+# ifdef SIGDGNOTIFY
+      sys_siglist[SIGDGNOTIFY] = "Notification message in queue";
+# endif
+# ifdef SIGEMT
+      sys_siglist[SIGEMT] = "Emulation trap";
+# endif
+# ifdef SIGFPE
+      sys_siglist[SIGFPE] = "Arithmetic exception";
+# endif
+# ifdef SIGFREEZE
+      sys_siglist[SIGFREEZE] = "SIGFREEZE";
+# endif
+# ifdef SIGGRANT
+      sys_siglist[SIGGRANT] = "Monitor mode granted";
+# endif
+# ifdef SIGHUP
+      sys_siglist[SIGHUP] = "Hangup";
+# endif
+# ifdef SIGILL
+      sys_siglist[SIGILL] = "Illegal instruction";
+# endif
+# ifdef SIGINT
+      sys_siglist[SIGINT] = "Interrupt";
+# endif
+# ifdef SIGIO
+      sys_siglist[SIGIO] = "I/O possible";
+# endif
+# ifdef SIGIOINT
+      sys_siglist[SIGIOINT] = "I/O intervention required";
+# endif
+# ifdef SIGIOT
+      sys_siglist[SIGIOT] = "IOT trap";
+# endif
+# ifdef SIGKILL
+      sys_siglist[SIGKILL] = "Killed";
+# endif
+# ifdef SIGLOST
+      sys_siglist[SIGLOST] = "Resource lost";
+# endif
+# ifdef SIGLWP
+      sys_siglist[SIGLWP] = "SIGLWP";
+# endif
+# ifdef SIGMSG
+      sys_siglist[SIGMSG] = "Monitor mode data available";
+# endif
+# ifdef SIGPHONE
+      sys_siglist[SIGWIND] = "SIGPHONE";
+# endif
+# ifdef SIGPIPE
+      sys_siglist[SIGPIPE] = "Broken pipe";
+# endif
+# ifdef SIGPOLL
+      sys_siglist[SIGPOLL] = "Pollable event occurred";
+# endif
+# ifdef SIGPROF
+      sys_siglist[SIGPROF] = "Profiling timer expired";
+# endif
+# ifdef SIGPTY
+      sys_siglist[SIGPTY] = "PTY I/O interrupt";
+# endif
+# ifdef SIGPWR
+      sys_siglist[SIGPWR] = "Power-fail restart";
+# endif
+# ifdef SIGQUIT
+      sys_siglist[SIGQUIT] = "Quit";
+# endif
+# ifdef SIGRETRACT
+      sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode";
+# endif
+# ifdef SIGSAK
+      sys_siglist[SIGSAK] = "Secure attention";
+# endif
+# ifdef SIGSEGV
+      sys_siglist[SIGSEGV] = "Segmentation violation";
+# endif
+# ifdef SIGSOUND
+      sys_siglist[SIGSOUND] = "Sound completed";
+# endif
+# ifdef SIGSTOP
+      sys_siglist[SIGSTOP] = "Stopped (signal)";
+# endif
+# ifdef SIGSTP
+      sys_siglist[SIGSTP] = "Stopped (user)";
+# endif
+# ifdef SIGSYS
+      sys_siglist[SIGSYS] = "Bad argument to system call";
+# endif
+# ifdef SIGTERM
+      sys_siglist[SIGTERM] = "Terminated";
+# endif
+# ifdef SIGTHAW
+      sys_siglist[SIGTHAW] = "SIGTHAW";
+# endif
+# ifdef SIGTRAP
+      sys_siglist[SIGTRAP] = "Trace/breakpoint trap";
+# endif
+# ifdef SIGTSTP
+      sys_siglist[SIGTSTP] = "Stopped (user)";
+# endif
+# ifdef SIGTTIN
+      sys_siglist[SIGTTIN] = "Stopped (tty input)";
+# endif
+# ifdef SIGTTOU
+      sys_siglist[SIGTTOU] = "Stopped (tty output)";
+# endif
+# ifdef SIGURG
+      sys_siglist[SIGURG] = "Urgent I/O condition";
+# endif
+# ifdef SIGUSR1
+      sys_siglist[SIGUSR1] = "User defined signal 1";
+# endif
+# ifdef SIGUSR2
+      sys_siglist[SIGUSR2] = "User defined signal 2";
+# endif
+# ifdef SIGVTALRM
+      sys_siglist[SIGVTALRM] = "Virtual timer expired";
+# endif
+# ifdef SIGWAITING
+      sys_siglist[SIGWAITING] = "Process's LWPs are blocked";
+# endif
+# ifdef SIGWINCH
+      sys_siglist[SIGWINCH] = "Window size changed";
+# endif
+# ifdef SIGWIND
+      sys_siglist[SIGWIND] = "SIGWIND";
+# endif
+# ifdef SIGXCPU
+      sys_siglist[SIGXCPU] = "CPU time limit exceeded";
+# endif
+# ifdef SIGXFSZ
+      sys_siglist[SIGXFSZ] = "File size limit exceeded";
+# endif
+    }
+#endif /* !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED */
+}
+\f
 #ifndef HAVE_RANDOM
 #ifdef random
 #define HAVE_RANDOM
 #ifndef HAVE_RANDOM
 #ifdef random
 #define HAVE_RANDOM
@@ -3093,27 +3219,25 @@ strerror (errnum)
 #endif /* not WINDOWSNT */
 #endif /* ! HAVE_STRERROR */
 \f
 #endif /* not WINDOWSNT */
 #endif /* ! HAVE_STRERROR */
 \f
-#ifdef INTERRUPTIBLE_OPEN
-
 int
 int
-/* VARARGS 2 */
-sys_open (path, oflag, mode)
+emacs_open (path, oflag, mode)
      char *path;
      int oflag, mode;
 {
   register int rtnval;
      char *path;
      int oflag, mode;
 {
   register int rtnval;
+
+#ifdef BSD4_1
+  if (oflag & O_CREAT) 
+    return creat (path, mode);
+#endif
   
   while ((rtnval = open (path, oflag, mode)) == -1
         && (errno == EINTR));
   return (rtnval);
 }
 
   
   while ((rtnval = open (path, oflag, mode)) == -1
         && (errno == EINTR));
   return (rtnval);
 }
 
-#endif /* INTERRUPTIBLE_OPEN */
-
-#ifdef INTERRUPTIBLE_CLOSE
-
 int
 int
-sys_close (fd)
+emacs_close (fd)
      int fd;
 {
   int did_retry = 0;
      int fd;
 {
   int did_retry = 0;
@@ -3132,12 +3256,8 @@ sys_close (fd)
   return rtnval;
 }
 
   return rtnval;
 }
 
-#endif /* INTERRUPTIBLE_CLOSE */
-
-#ifdef INTERRUPTIBLE_IO
-
 int
 int
-sys_read (fildes, buf, nbyte)
+emacs_read (fildes, buf, nbyte)
      int fildes;
      char *buf;
      unsigned int nbyte;
      int fildes;
      char *buf;
      unsigned int nbyte;
@@ -3150,7 +3270,7 @@ sys_read (fildes, buf, nbyte)
 }
 
 int
 }
 
 int
-sys_write (fildes, buf, nbyte)
+emacs_write (fildes, buf, nbyte)
      int fildes;
      char *buf;
      unsigned int nbyte;
      int fildes;
      char *buf;
      unsigned int nbyte;
@@ -3177,8 +3297,6 @@ sys_write (fildes, buf, nbyte)
     }
   return (bytes_written);
 }
     }
   return (bytes_written);
 }
-
-#endif /* INTERRUPTIBLE_IO */
 \f
 #ifndef HAVE_VFORK
 #ifndef WINDOWSNT
 \f
 #ifndef HAVE_VFORK
 #ifndef WINDOWSNT
@@ -3210,93 +3328,6 @@ vfork ()
  *     always negligible.   Fred Fish, Unisoft Systems Inc.
  */
 
  *     always negligible.   Fred Fish, Unisoft Systems Inc.
  */
 
-#ifndef HAVE_SYS_SIGLIST
-char *sys_siglist[NSIG + 1] =
-{
-#ifdef AIX
-/* AIX has changed the signals a bit */
-  "bogus signal",                      /* 0 */
-  "hangup",                            /* 1  SIGHUP */
-  "interrupt",                         /* 2  SIGINT */
-  "quit",                              /* 3  SIGQUIT */
-  "illegal instruction",               /* 4  SIGILL */
-  "trace trap",                                /* 5  SIGTRAP */
-  "IOT instruction",                   /* 6  SIGIOT */
-  "crash likely",                      /* 7  SIGDANGER */
-  "floating point exception",          /* 8  SIGFPE */
-  "kill",                              /* 9  SIGKILL */
-  "bus error",                         /* 10 SIGBUS */
-  "segmentation violation",            /* 11 SIGSEGV */
-  "bad argument to system call",       /* 12 SIGSYS */
-  "write on a pipe with no one to read it", /* 13 SIGPIPE */
-  "alarm clock",                       /* 14 SIGALRM */
-  "software termination signum",       /* 15 SIGTERM */
-  "user defined signal 1",             /* 16 SIGUSR1 */
-  "user defined signal 2",             /* 17 SIGUSR2 */
-  "death of a child",                  /* 18 SIGCLD */
-  "power-fail restart",                        /* 19 SIGPWR */
-  "bogus signal",                      /* 20 */
-  "bogus signal",                      /* 21 */
-  "bogus signal",                      /* 22 */
-  "bogus signal",                      /* 23 */
-  "bogus signal",                      /* 24 */
-  "LAN I/O interrupt",                 /* 25 SIGAIO */
-  "PTY I/O interrupt",                 /* 26 SIGPTY */
-  "I/O intervention required",         /* 27 SIGIOINT */
-#ifdef AIXHFT
-  "HFT grant",                         /* 28 SIGGRANT */
-  "HFT retract",                       /* 29 SIGRETRACT */
-  "HFT sound done",                    /* 30 SIGSOUND */
-  "HFT input ready",                   /* 31 SIGMSG */
-#endif
-#else /* not AIX */
-  "bogus signal",                      /* 0 */
-  "hangup",                            /* 1  SIGHUP */
-  "interrupt",                         /* 2  SIGINT */
-  "quit",                              /* 3  SIGQUIT */
-  "illegal instruction",               /* 4  SIGILL */
-  "trace trap",                                /* 5  SIGTRAP */
-  "IOT instruction",                   /* 6  SIGIOT */
-  "EMT instruction",                   /* 7  SIGEMT */
-  "floating point exception",          /* 8  SIGFPE */
-  "kill",                              /* 9  SIGKILL */
-  "bus error",                         /* 10 SIGBUS */
-  "segmentation violation",            /* 11 SIGSEGV */
-  "bad argument to system call",       /* 12 SIGSYS */
-  "write on a pipe with no one to read it", /* 13 SIGPIPE */
-  "alarm clock",                       /* 14 SIGALRM */
-  "software termination signum",       /* 15 SIGTERM */
-  "user defined signal 1",             /* 16 SIGUSR1 */
-  "user defined signal 2",             /* 17 SIGUSR2 */
-  "death of a child",                  /* 18 SIGCLD */
-  "power-fail restart",                        /* 19 SIGPWR */
-#ifdef sun
-  "window size change",                            /* 20 SIGWINCH */
-  "urgent socket condition",               /* 21 SIGURG */
-  "pollable event occurred",               /* 22 SIGPOLL */
-  "stop (cannot be caught or ignored)", /*  23 SIGSTOP */
-  "user stop requested from tty",          /* 24 SIGTSTP */
-  "stopped process has been continued",        /* 25 SIGCONT */
-  "background tty read attempted",         /* 26 SIGTTIN */
-  "background tty write attempted",    /* 27 SIGTTOU */
-  "virtual timer expired",                 /* 28 SIGVTALRM */
-  "profiling timer expired",               /* 29 SIGPROF */
-  "exceeded cpu limit",                            /* 30 SIGXCPU */
-  "exceeded file size limit",              /* 31 SIGXFSZ */
-  "process's lwps are blocked",            /*  32 SIGWAITING */
-  "special signal used by thread library", /* 33 SIGLWP */
-#ifdef SIGFREEZE
-  "Special Signal Used By CPR",            /* 34 SIGFREEZE */
-#endif
-#ifdef SIGTHAW
-  "Special Signal Used By CPR",            /* 35 SIGTHAW */
-#endif
-#endif /* sun */
-#endif /* not AIX */
-  0
-  };
-#endif /* HAVE_SYS_SIGLIST */
-
 /*
  *     Warning, this function may not duplicate 4.2 action properly
  *     under error conditions.
 /*
  *     Warning, this function may not duplicate 4.2 action properly
  *     under error conditions.
@@ -3384,12 +3415,10 @@ dup2 (oldd, newd)
 {
   register int fd, ret;
   
 {
   register int fd, ret;
   
-  sys_close (newd);
+  emacs_close (newd);
 
 #ifdef F_DUPFD
 
 #ifdef F_DUPFD
-  fd = fcntl (oldd, F_DUPFD, newd);
-  if (fd != newd)
-    error ("can't dup2 (%i,%i) : %s", oldd, newd, strerror (errno));
+  return fcntl (oldd, F_DUPFD, newd);
 #else
   fd = dup (old);
   if (fd == -1)
 #else
   fd = dup (old);
   if (fd == -1)
@@ -3397,7 +3426,7 @@ dup2 (oldd, newd)
   if (fd == new)
     return new;
   ret = dup2 (old,new);
   if (fd == new)
     return new;
   ret = dup2 (old,new);
-  sys_close (fd);
+  emacs_close (fd);
   return ret;
 #endif
 }
   return ret;
 #endif
 }
@@ -3450,80 +3479,6 @@ croak (badfunc)
 
 #endif /* USG */
 \f
 
 #endif /* USG */
 \f
-#ifdef DGUX
-
-char *sys_siglist[NSIG + 1] =
-{
-  "null signal",                        /*  0 SIGNULL   */
-  "hangup",                             /*  1 SIGHUP    */
-  "interrupt",                          /*  2 SIGINT    */
-  "quit",                               /*  3 SIGQUIT   */
-  "illegal instruction",                /*  4 SIGILL    */
-  "trace trap",                                 /*  5 SIGTRAP   */
-  "abort termination",                  /*  6 SIGABRT   */
-  "SIGEMT",                             /*  7 SIGEMT    */
-  "floating point exception",           /*  8 SIGFPE    */
-  "kill",                               /*  9 SIGKILL   */
-  "bus error",                          /* 10 SIGBUS    */
-  "segmentation violation",             /* 11 SIGSEGV   */
-  "bad argument to system call",        /* 12 SIGSYS    */
-  "write on a pipe with no reader",     /* 13 SIGPIPE   */
-  "alarm clock",                        /* 14 SIGALRM   */
-  "software termination signal",        /* 15 SIGTERM   */
-  "user defined signal 1",              /* 16 SIGUSR1   */
-  "user defined signal 2",              /* 17 SIGUSR2   */
-  "child stopped or terminated",        /* 18 SIGCLD    */
-  "power-fail restart",                         /* 19 SIGPWR    */
-  "window size changed",                /* 20 SIGWINCH  */
-  "undefined",                          /* 21           */
-  "pollable event occurred",            /* 22 SIGPOLL   */
-  "sendable stop signal not from tty",  /* 23 SIGSTOP   */
-  "stop signal from tty",               /* 24 SIGSTP    */
-  "continue a stopped process",                 /* 25 SIGCONT   */
-  "attempted background tty read",      /* 26 SIGTTIN   */
-  "attempted background tty write",     /* 27 SIGTTOU   */
-  "undefined",                          /* 28           */
-  "undefined",                          /* 29           */
-  "undefined",                          /* 30           */
-  "undefined",                          /* 31           */
-  "undefined",                          /* 32           */
-  "socket (TCP/IP) urgent data arrival", /* 33 SIGURG    */
-  "I/O is possible",                    /* 34 SIGIO     */
-  "exceeded cpu time limit",            /* 35 SIGXCPU   */
-  "exceeded file size limit",           /* 36 SIGXFSZ   */
-  "virtual time alarm",                         /* 37 SIGVTALRM */
-  "profiling time alarm",               /* 38 SIGPROF   */
-  "undefined",                          /* 39           */
-  "file record locks revoked",          /* 40 SIGLOST   */
-  "undefined",                          /* 41           */
-  "undefined",                          /* 42           */
-  "undefined",                          /* 43           */
-  "undefined",                          /* 44           */
-  "undefined",                          /* 45           */
-  "undefined",                          /* 46           */
-  "undefined",                          /* 47           */
-  "undefined",                          /* 48           */
-  "undefined",                          /* 49           */
-  "undefined",                          /* 50           */
-  "undefined",                          /* 51           */
-  "undefined",                          /* 52           */
-  "undefined",                          /* 53           */
-  "undefined",                          /* 54           */
-  "undefined",                          /* 55           */
-  "undefined",                          /* 56           */
-  "undefined",                          /* 57           */
-  "undefined",                          /* 58           */
-  "undefined",                          /* 59           */
-  "undefined",                          /* 60           */
-  "undefined",                          /* 61           */
-  "undefined",                          /* 62           */
-  "undefined",                          /* 63           */
-  "notification message in mess. queue", /* 64 SIGDGNOTIFY */
-  0
-};
-
-#endif /* DGUX */
-\f
 /* Directory routines for systems that don't have them. */
 
 #ifdef SYSV_SYSTEM_DIR
 /* Directory routines for systems that don't have them. */
 
 #ifdef SYSV_SYSTEM_DIR
@@ -3538,7 +3493,7 @@ closedir (dirp)
 {
   int rtnval;
 
 {
   int rtnval;
 
-  rtnval = sys_close (dirp->dd_fd);
+  rtnval = emacs_close (dirp->dd_fd);
 
   /* Some systems (like Solaris) allocate the buffer and the DIR all
      in one block.  Why in the world are we freeing this ourselves
 
   /* Some systems (like Solaris) allocate the buffer and the DIR all
      in one block.  Why in the world are we freeing this ourselves
@@ -3563,7 +3518,7 @@ opendir (filename)
   register int fd;             /* file descriptor for read */
   struct stat sbuf;            /* result of fstat */
 
   register int fd;             /* file descriptor for read */
   struct stat sbuf;            /* result of fstat */
 
-  fd = sys_open (filename, 0);
+  fd = emacs_open (filename, O_RDONLY, 0);
   if (fd < 0)
     return 0;
 
   if (fd < 0)
     return 0;
 
@@ -3572,7 +3527,7 @@ opendir (filename)
       || (sbuf.st_mode & S_IFMT) != S_IFDIR
       || (dirp = (DIR *) malloc (sizeof (DIR))) == 0)
     {
       || (sbuf.st_mode & S_IFMT) != S_IFDIR
       || (dirp = (DIR *) malloc (sizeof (DIR))) == 0)
     {
-      sys_close (fd);
+      emacs_close (fd);
       UNBLOCK_INPUT;
       return 0;                /* bad luck today */
     }
       UNBLOCK_INPUT;
       return 0;                /* bad luck today */
     }
@@ -3588,7 +3543,7 @@ void
 closedir (dirp)
      register DIR *dirp;               /* stream from opendir */
 {
 closedir (dirp)
      register DIR *dirp;               /* stream from opendir */
 {
-  sys_close (dirp->dd_fd);
+  emacs_close (dirp->dd_fd);
   xfree ((char *) dirp);
 }
 
   xfree ((char *) dirp);
 }
 
@@ -3622,7 +3577,7 @@ readdir (dirp)
        dirp->dd_loc = dirp->dd_size = 0;
 
       if (dirp->dd_size == 0   /* refill buffer */
        dirp->dd_loc = dirp->dd_size = 0;
 
       if (dirp->dd_size == 0   /* refill buffer */
-         && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0)
+         && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0)
        return 0;
 
 #ifndef VMS
        return 0;
 
 #ifndef VMS
@@ -3775,7 +3730,7 @@ mkdir (dpath, dmode)
                 */
       status = umask (0);      /* Get current umask */
       status = umask (status | (0777 & ~dmode));       /* Set for mkdir */
                 */
       status = umask (0);      /* Get current umask */
       status = umask (status | (0777 & ~dmode));       /* Set for mkdir */
-      fd = sys_open ("/dev/null", 2);
+      fd = emacs_open ("/dev/null", O_RDWR, 0);
       if (fd >= 0)
         {
          dup2 (fd, 0);
       if (fd >= 0)
         {
          dup2 (fd, 0);
@@ -3821,7 +3776,7 @@ rmdir (dpath)
       return (-1);             /* Errno is set already */
 
     case 0:                    /* Child process */
       return (-1);             /* Errno is set already */
 
     case 0:                    /* Child process */
-      fd = sys_open ("/dev/null", 2);
+      fd = emacs_open ("/dev/null", O_RDWR, 0);
       if (fd >= 0)
         {
          dup2 (fd, 0);
       if (fd >= 0)
         {
          dup2 (fd, 0);
@@ -4240,6 +4195,7 @@ sys_getuid ()
   return (getgid () << 16) | getuid ();
 }
 
   return (getgid () << 16) | getuid ();
 }
 
+#undef read
 int
 sys_read (fildes, buf, nbyte)
      int fildes;
 int
 sys_read (fildes, buf, nbyte)
      int fildes;
@@ -4279,6 +4235,7 @@ sys_write (fildes, buf, nbyte)
  *     Thus we do this stupidity below.
  */
 
  *     Thus we do this stupidity below.
  */
 
+#undef write
 int
 sys_write (fildes, buf, nbytes)
      int fildes;
 int
 sys_write (fildes, buf, nbytes)
      int fildes;
@@ -5322,7 +5279,28 @@ bcmp (b1, b2, length)    /* This could be a macro! */
 }
 #endif /* no bcmp */
 #endif /* not BSTRING */
 }
 #endif /* no bcmp */
 #endif /* not BSTRING */
+\f
+#ifndef HAVE_STRSIGNAL
+char *
+strsignal (code)
+     int code;
+{
+  char *signame = 0;
 
 
+  if (0 <= code && code < NSIG)
+    {
+#ifdef VMS
+      signame = sys_errlist[code];
+#else
+      /* Cast to suppress warning if the table has const char *.  */
+      signame = (char *) sys_siglist[code];
+#endif
+    }
+
+  return signame;
+}
+#endif /* HAVE_STRSIGNAL */
+\f
 /* All the Macintosh stuffs go here */
 
 #ifdef macintosh
 /* All the Macintosh stuffs go here */
 
 #ifdef macintosh
@@ -5502,10 +5480,10 @@ Unix2MacPathname (const char *ufn, char *mfn, int mfnbuflen)
 
 /* Define our own stat function for both MrC and CW.  The reason for
    doing this: "stat" is both the name of a struct and function name:
 
 /* Define our own stat function for both MrC and CW.  The reason for
    doing this: "stat" is both the name of a struct and function name:
-   can't use the same trick like that for sys_open, sys_close, etc. to
+   we can't #define stat to something else to
    redirect Emacs's calls to our own version that converts Unix style
    filenames to Mac style filename because all sorts of compilation
    redirect Emacs's calls to our own version that converts Unix style
    filenames to Mac style filename because all sorts of compilation
-   errors will be generated if stat is #define'd to be sys_stat.  */
+   errors will be generated if stat is #define'd to be something else.  */
 
 int
 stat (const char *path, struct stat *buf)
 
 int
 stat (const char *path, struct stat *buf)
@@ -6402,33 +6380,6 @@ getenv (const char * name)
     return (NULL);
 }
 
     return (NULL);
 }
 
-#ifdef __MRC__
-/* see Interfaces&Libraries:Interfaces:CIncludes:signal.h */
-char *sys_siglist[] =
-{
-  "Zero is not a signal!!!",
-  "Abort",  /* 1 */
-  "Interactive user interrupt",  /* 2 */  "BAD",
-  "Floating point exception",  /* 4 */  "BAD", "BAD", "BAD",
-  "Illegal instruction",  /* 8 */  "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD",
-  "Segment violation",  /* 16 */  "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD", "BAD",
-  "Terminal"  /* 32 */
-};
-#elif __MWERKS__
-char *sys_siglist[] =
-{
-  "Zero is not a signal!!!",
-  "Abort",
-  "Floating point exception",
-  "Illegal instruction",
-  "Interactive user interrupt",
-  "Segment violation",
-  "Terminal"
-};
-#else
-You lose!!!
-#endif
-
 #ifdef __MRC__
 #include <utsname.h>
 
 #ifdef __MRC__
 #include <utsname.h>