(U-0002195D): Add `ideographic-structure'; add `sound@ja/on'; add
[chise/xemacs-chise.git.1] / src / unexec.c
index 907b5cf..fae0162 100644 (file)
@@ -136,7 +136,7 @@ before writing it (above and beyond the number of bytes of actual
 program text).  HDR's standard fields are already correct, except that
 this adjustment to the `a_text' field has not yet been made;
 thus, the amount of offset can depend on the data in the file.
-  
+
 * A_TEXT_SEEK(HDR)
 
 If defined, this macro specifies the number of bytes to seek into the
@@ -186,17 +186,12 @@ pointer looks like an int) but not on all machines.
 #  undef _POSIX_SOURCE
 # endif
 
-# if defined(__lucid) && !defined(__STDC_EXTENDED__)
-#  define __STDC_EXTENDED__ 1
-# endif
-
+# include <stddef.h>
 # include <stdlib.h>
 # include <unistd.h>
 # include <string.h>
-
-# ifdef __lucid
-#  include <sysent.h>
-# endif
+# include <stddef.h>
+# include <errno.h>
 
 #endif
 
@@ -214,33 +209,7 @@ pointer looks like an int) but not on all machines.
 int need_coff_header = 1;
 #include <coff-encap/a.out.encap.h> /* The location might be a poor assumption */
 #else
-#ifdef MSDOS
-#if __DJGPP__ > 1
-#include <fcntl.h>  /* for O_RDONLY, O_RDWR */
-#endif
-#include <coff.h>
-#define filehdr external_filehdr
-#define scnhdr external_scnhdr
-#define syment external_syment
-#define auxent external_auxent
-#define n_numaux e_numaux
-#define n_type e_type
-struct aouthdr
-{
-  unsigned short       magic;  /* type of file                         */
-  unsigned short       vstamp; /* version stamp                        */
-  unsigned long                tsize;  /* text size in bytes, padded to FW bdry*/
-  unsigned long                dsize;  /* initialized data "  "                */
-  unsigned long                bsize;  /* uninitialized data "   "             */
-  unsigned long                entry;  /* entry pt.                            */
-  unsigned long                text_start;/* base of text used for this file */
-  unsigned long                data_start;/* base of data used for this file */
-};
-
-
-#else /* not MSDOS */
 #include <a.out.h>
-#endif /* not MSDOS */
 #endif /* not COFF_ENCAPSULATE */
 
 /* Define getpagesize if the system does not.
@@ -287,7 +256,7 @@ static long data_scnptr;
 
 #ifdef __STDC__
 #ifndef __sys_stdtypes_h
-#ifndef _PTRDIFF_T
+#if !defined(_PTRDIFF_T) && !defined(_BSD_PTRDIFF_T_)
 typedef long ptrdiff_t;
 #endif
 #endif
@@ -371,14 +340,12 @@ static int pagemask;
 #include "lisp.h"
 
 static void
-report_error (file, fd)
-     CONST char *file;
-     int fd;
+report_error (const char *file, int fd)
 {
   if (fd)
     close (fd);
   report_file_error ("Cannot unexec",
-                    Fcons (build_ext_string (file, FORMAT_FILENAME), Qnil));
+                    Fcons (build_ext_string (file, Qfile_name), Qnil));
 }
 #endif /* emacs */
 
@@ -389,7 +356,7 @@ report_error (file, fd)
 static void
 report_error_1 (fd, msg, a1, a2)
      int fd;
-     CONST char *msg;
+     const char *msg;
      int a1, a2;
 {
   close (fd);
@@ -441,7 +408,7 @@ unexec (new_name, a_name, data_start, bss_start, entry_address)
     {
       close (new);
       /* unlink (new_name);            / * Failed, unlink new a.out */
-      return -1;       
+      return -1;
     }
 
   close (new);
@@ -918,14 +885,6 @@ copy_text_and_data (int new, int a_out)
 
 #else /* COFF, but not USG_SHARED_LIBRARIES */
 
-#ifdef MSDOS
-#if __DJGPP__ >= 2
-  /* Dump the original table of exception handlers, not the one
-     where our exception hooks are registered.  */
-  __djgpp_exception_toggle ();
-#endif
-#endif
-
   lseek (new, (long) text_scnptr, 0);
   ptr = (char *) f_ohdr.text_start;
 #ifdef HEADER_INCL_IN_TEXT
@@ -940,13 +899,6 @@ copy_text_and_data (int new, int a_out)
   end = ptr + f_ohdr.dsize;
   write_segment (new, ptr, end);
 
-#ifdef MSDOS
-#if __DJGPP__ >= 2
-  /* Restore our exception hooks.  */
-  __djgpp_exception_toggle ();
-#endif
-#endif
-
 #endif /* USG_SHARED_LIBRARIES */
 
 #else /* if not COFF */
@@ -967,7 +919,7 @@ copy_text_and_data (int new, int a_out)
 
 #ifdef RISCiX
 
-  /* Acorn's RISC-iX has a wacky way of initialising the position of the heap.
+  /* Acorn's RISC-iX has a wacky way of initializing the position of the heap.
    * There is a little table in crt0.o that is filled at link time with
    * the min and current brk positions, among other things.  When start
    * runs, it copies the table to where these parameters live during
@@ -996,7 +948,7 @@ copy_text_and_data (int new, int a_out)
     char c;
     int mcount_address, mcount_offset, count;
     extern char *_execname;
-   
+
 
     /* The use of _execname is incompatible with RISCiX 1.1 */
     sprintf (command, "nm %s | fgrep mcount", _execname);
@@ -1016,7 +968,7 @@ copy_text_and_data (int new, int a_out)
     {
       sprintf (errbuf, "Failed to execute the command '%s'\n", command);
       PERROR (errbuf);
-    }  
+    }
 
     sscanf(address_text, "%x", &mcount_address);
     ptr = (char *) unexec_text_start;
@@ -1074,7 +1026,6 @@ write_segment (new, ptr, end)
 #if 0
   char buf[80];
 #endif
-  extern int errno;
   /* This is the normal amount to write at once.
      It is the size of block that NFS uses.  */
   int writesize = 1 << 13;
@@ -1229,11 +1180,7 @@ adjust_lnnoptrs (writedesc, readdesc, new_name)
   if (!lnnoptr || !f_hdr.f_symptr)
     return 0;
 
-#ifdef MSDOS
-  if ((new = writedesc) < 0)
-#else
   if ((new = open (new_name, O_RDWR)) < 0)
-#endif
     {
       PERROR (new_name);
       return -1;
@@ -1255,9 +1202,7 @@ adjust_lnnoptrs (writedesc, readdesc, new_name)
            }
        }
     }
-#ifndef MSDOS
   close (new);
-#endif
   return 0;
 }