*** empty log message ***
[bpt/emacs.git] / src / sysdep.c
index 63e0991..a9b426e 100644 (file)
@@ -22,6 +22,9 @@ Boston, MA 02111-1307, USA.  */
 #include <config.h>
 #include <signal.h>
 #include <setjmp.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include "lisp.h"
 #include "blockinput.h"
@@ -51,7 +54,9 @@ Lisp_Object Vx_bitmap_file_path;
 #define read sys_read
 #define write sys_write
 #include <windows.h>
-extern int errno;
+#ifndef NULL
+#define NULL 0
+#endif
 #endif /* not WINDOWSNT */
 
 /* Does anyone other than VMS need this? */
@@ -75,6 +80,17 @@ extern int h_errno;
 #include <unistd.h>
 #endif
 
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_SETPGID
+#if !defined (USG) || defined (BSD_PGRPS)
+#undef setpgrp
+#define setpgrp setpgid
+#endif
+#endif
+
 /* Get SI_SRPC_DOMAIN, if it is available.  */
 #ifdef HAVE_SYS_SYSTEMINFO_H
 #include <sys/systeminfo.h>
@@ -92,9 +108,11 @@ extern unsigned start __asm__ ("start");
 #endif
 #endif
 
+#ifndef USE_CRT_DLL
 #ifndef errno
 extern int errno;
 #endif
+#endif
 
 #ifdef VMS
 #include <rms.h>
@@ -162,6 +180,7 @@ extern int errno;
 
 extern int quit_char;
 
+#include "keyboard.h"
 #include "frame.h"
 #include "window.h"
 #include "termhooks.h"
@@ -199,10 +218,6 @@ struct utimbuf {
 #endif
 #endif
 
-#ifndef VFORK_RETURN_TYPE
-#define VFORK_RETURN_TYPE int
-#endif
-
 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits.  */
 #ifndef LPASS8
 #define LPASS8 0
@@ -222,6 +237,10 @@ static int baud_convert[] =
   };
 #endif
 
+#ifdef HAVE_SPEED_T
+#include <termios.h>
+extern speed_t ospeed;
+#else
 #if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T)
 extern short ospeed;
 #else
@@ -234,6 +253,7 @@ extern speed_t ospeed;
 extern short ospeed;
 #endif
 #endif
+#endif
 
 /* The file descriptor for Emacs's input terminal.
    Under Unix, this is normally zero except when using X;
@@ -247,6 +267,10 @@ void hft_init ();
 void hft_reset ();
 #endif
 
+/* Temporary used by `sigblock' when defined in terms of signprocmask.  */
+
+SIGMASKTYPE sigprocmask_set;
+
 \f
 /* Specify a different file descriptor for further input operations.  */
 
@@ -3506,7 +3530,7 @@ opendir (filename)
   BLOCK_INPUT;
   if (fstat (fd, &sbuf) < 0
       || (sbuf.st_mode & S_IFMT) != S_IFDIR
-      || (dirp = (DIR *) malloc (sizeof (DIR))) == 0)
+      || (dirp = (DIR *) xmalloc (sizeof (DIR))) == 0)
     {
       emacs_close (fd);
       UNBLOCK_INPUT;
@@ -6335,7 +6359,7 @@ GetTempDirName ()
       else if (mkdir (unixDirName, 0700) != 0)  /* create it if not */
        return NULL;
 
-      TempDirName = (char *) malloc (strlen (unixDirName) + 1);
+      TempDirName = (char *) xmalloc (strlen (unixDirName) + 1);
       strcpy (TempDirName, unixDirName);
     }
 
@@ -6485,8 +6509,8 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
     {
       char *command, *t, tempmacpathname[MAXPATHLEN+1];
     
-      /* The arguments for the command in argv[2] are separated by spaces.  Count them and put
-        the count in newargc.  */
+      /* The arguments for the command in argv[2] are separated by
+        spaces.  Count them and put the count in newargc.  */
       command = (char *) alloca (strlen (argv[2])+2);
       strcpy (command, argv[2]);
       if (command[strlen (command) - 1] != ' ')
@@ -6575,7 +6599,7 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
 
   /* After expanding all the arguments, we now know the length of the parameter block to be
      sent to the subprocess as a message attached to the HLE. */
-  param = (char *) malloc (paramlen + 1);
+  param = (char *) xmalloc (paramlen + 1);
   if (!param)
     return -1;
 
@@ -6604,7 +6628,7 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
   iErr = FSMakeFSSpec (0, 0, macappname, &spec);
   
   if (iErr != noErr) {
-    free (param);
+    xfree (param);
     return -1;
   }
 
@@ -6615,10 +6639,11 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
   lpbr.launchAppParameters = NULL;
 
   iErr = LaunchApplication (&lpbr);  /* call the subprocess */
-  if (iErr != noErr) {
-    free (param);
-    return -1;
-  }
+  if (iErr != noErr)
+    {
+      xfree (param);
+      return -1;
+    }
 
   sendEvent.what = kHighLevelEvent;
   sendEvent.message = kEmacsSubprocessSend;  /* Event ID stored in "where" unused */
@@ -6630,7 +6655,7 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
   while (iErr == sessClosedErr && retries-- > 0);
 
   if (iErr != noErr) {
-    free (param);
+    xfree (param);
     return -1;
   }
 
@@ -6645,12 +6670,12 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
   iErr = AcceptHighLevelEvent (&targ, &refCon, NULL, &len);
   if (iErr != noErr) {
     DisposeHandle ((Handle) cursorRegionHdl);
-    free (param);
+    xfree (param);
     return -1;
   }
   
   DisposeHandle ((Handle) cursorRegionHdl);
-  free (param);
+  xfree (param);
 
   return refCon;
 }
@@ -6663,7 +6688,7 @@ opendir (const char *dirname)
   CInfoPBRec cipb;
   int len;
 
-  dirp = (DIR *) malloc (sizeof (DIR));
+  dirp = (DIR *) xmalloc (sizeof (DIR));
   if (!dirp)
     return 0;
 
@@ -6709,8 +6734,7 @@ opendir (const char *dirname)
 int
 closedir (DIR *dp)
 {
-  free (dp);
-
+  xfree (dp);
   return 0;
 }