(X_WINDOWS_SUPPORT): Don't include term/x-win.
[bpt/emacs.git] / src / unexsunos4.c
index b5d8082..fd0f7ec 100644 (file)
  *  is somewhat abused here) is loaded first!
  *
  */
-#ifdef emacs
-#include "config.h"
-#endif
-
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/file.h>
 #include <stdio.h>
 #include <a.out.h>
 
+/* Do this after the above #include's in case a configuration file wants
+   to define things for this file based on what <a.out.h> defines.  */
+#ifdef emacs
+#include <config.h>
+#endif
+
+
+/* NetBSD needs this bit, but SunOS does not have it.  */
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+
+
 /*
  * for programs other than emacs
  * define data_start + initialized here,  and make sure
@@ -63,7 +72,6 @@ unexec (new_name, a_name, bndry, bss_start, entry)
      char *new_name, *a_name;
      unsigned bndry, bss_start, entry;
 {
-  char buf[PAGSIZ];
   int fd, new;
   char *old;
   struct exec ohdr;            /* Allocate on the stack,  not needed in the next life */
@@ -93,7 +101,7 @@ unexec (new_name, a_name, bndry, bss_start, entry)
       exit (1);
     }
 
-  old = (char *)mmap (0, stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+  old = (char *)mmap (0, stat.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0);
   if (old == (char *)-1)
     {
       fprintf (stderr, "%s: ", a_name);
@@ -106,8 +114,8 @@ unexec (new_name, a_name, bndry, bss_start, entry)
 
 
   /*
-   * Remeber a magic cookie so we know we've got the right binary
-   * when remaping.
+   * Remember a magic cookie so we know we've got the right binary
+   * when remapping.
    */
   cookie = time (0);
 
@@ -267,7 +275,7 @@ is_it (path)
               * addresses in the data segment not part of __DYNAMIC
               */
              mmap (data_start, rd_only_len, PROT_READ | PROT_EXEC,
-                   MAP_SHARED | MAP_FIXED, fd,
+                   MAP_FILE | MAP_SHARED | MAP_FIXED, fd,
                    N_DATOFF (hdr) + data_start - N_DATADDR (hdr));
              close (fd);
              return 1;