[comp.emacs] Convex configuration files

montnaro@sprite (Skip Montanaro) (04/28/88)

I noticed a couple people asking about GNU Emacs mods for Convex iron
running Dynix 6.1 (is Dynix what Convex calls UNIX?) with the SOFF format
files. I thought somebody else would post the following mods, so I held off
for a couple days to avoid needless net load.

We are using the following m-convex.h, config.h, and unexec.c files on a C2.
Try 'em and see if they work for you, the C1 and C2 machines are supposed to
be compatible. Credit for the mods goes to jthomp@convex.uucp.
--
Skip Montanaro (montanaro@sprite.steinmetz.ge.com, montanaro@ge-crd.arpa)
(beware the signature at the end!)

:
#!/bin/sh
# shar+ created from directory /temp/sprite
# by montnaro Thu Apr 28 11:55:36 EDT 1988
echo 'x - unexec.c (text)'
sed << 'E!O!F' 's/^X//' > unexec.c
X/* Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
X
X		       NO WARRANTY
X
X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
XCORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
X
X		GENERAL PUBLIC LICENSE TO COPY
X
X  1. You may copy and distribute verbatim copies of this source file
Xas you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy a valid copyright notice "Copyright
X(C) 1987 Free Software Foundation, Inc."; and include following the
Xcopyright notice a verbatim copy of the above disclaimer of warranty
Xand of this License.  You may charge a distribution fee for the
Xphysical act of transferring a copy.
X
X  2. You may modify your copy or copies of this source file or
Xany portion of it, and copy and distribute such modifications under
Xthe terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of this
X    program or any part thereof, to be licensed at no charge to all
X    third parties on terms identical to those contained in this
X    License Agreement (except that you may choose to grant more
X    extensive warranty protection to third parties, at your option).
X
X    c) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
X  3. You may copy and distribute this program or any portion of it in
Xcompiled, executable or object code form under the terms of Paragraphs
X1 and 2 above provided that you do the following:
X
X    a) cause each such copy to be accompanied by the
X    corresponding machine-readable source code, which must
X    be distributed under the terms of Paragraphs 1 and 2 above; or,
X
X    b) cause each such copy to be accompanied by a
X    written offer, with no time limit, to give any third party
X    free (except for a nominal shipping charge) a machine readable
X    copy of the corresponding source code, to be distributed
X    under the terms of Paragraphs 1 and 2 above; or,
X
X    c) in the case of a recipient of this program in compiled, executable
X    or object code form (without the corresponding source code) you
X    shall cause copies you distribute to be accompanied by a copy
X    of the written offer of source code which you received along
X    with the copy you received.
X
X  4. You may not copy, sublicense, distribute or transfer this program
Xexcept as expressly provided under this License Agreement.  Any attempt
Xotherwise to copy, sublicense, distribute or transfer this program is void and
Xyour rights to use the program under this License agreement shall be
Xautomatically terminated.  However, parties who have received computer
Xsoftware programs from you with this License Agreement will not have
Xtheir licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of this program into other free
Xprograms whose distribution conditions are different, write to the Free
XSoftware Foundation at 1000 Mass Ave, Cambridge, MA 02138.  We have not yet
Xworked out a simple rule that can be stated here, but we will often permit
Xthis.  We will be guided by the two goals of preserving the free status of
Xall derivatives of our free software and of promoting the sharing and reuse of
Xsoftware.
X
X
XIn other words, you are welcome to use, share and improve this program.
XYou are forbidden to forbid anyone else to use, share and improve
Xwhat you give them.   Help stamp out software-hoarding!  */
X
X
X/* modifyed for C-1 arch by jthomp@convex 871103 */
X
X/*
X * unexec.c - Convert a running program into an a.out file.
X *
X * Author:	Spencer W. Thomas
X * 		Computer Science Dept.
X * 		University of Utah
X * Date:	Tue Mar  2 1982
X * Modified heavily since then.
X *
X * Synopsis:
X *	unexec (new_name, a_name, data_start, bss_start, entry_address)
X *	char *new_name, *a_name;
X *	unsigned data_start, bss_start, entry_address;
X *
X * Takes a snapshot of the program and makes an a.out format file in the
X * file named by the string argument new_name.
X * If a_name is non-NULL, the symbol table will be taken from the given file.
X * On some machines, an existing a_name file is required.
X *
X * The boundaries within the a.out file may be adjusted with the data_start
X * and bss_start arguments.  Either or both may be given as 0 for defaults.
X *
X * Data_start gives the boundary between the text segment and the data
X * segment of the program.  The text segment can contain shared, read-only
X * program code and literal data, while the data segment is always unshared
X * and unprotected.  Data_start gives the lowest unprotected address.
X * The value you specify may be rounded down to a suitable boundary
X * as required by the machine you are using.
X *
X * Specifying zero for data_start means the boundary between text and data
X * should not be the same as when the program was loaded.
X * If NO_REMAP is defined, the argument data_start is ignored and the
X * segment boundaries are never changed.
X *
X * Bss_start indicates how much of the data segment is to be saved in the
X * a.out file and restored when the program is executed.  It gives the lowest
X * unsaved address, and is rounded up to a page boundary.  The default when 0
X * is given assumes that the entire data segment is to be stored, including
X * the previous data and bss as well as any additional storage allocated with
X * break (2).
X *
X * The new file is set up to start at entry_address.
X *
X * If you make improvements I'd like to get them too.
X * harpo!utah-cs!thomas, thomas@Utah-20
X *
X */
X
X/* There are several compilation parameters affecting unexec:
X
X* COFF
X
XDefine this if your system uses COFF for executables.
XOtherwise we assume you use Berkeley format.
X
X* NO_REMAP
X
XDefine this if you do not want to try to save Emacs's pure data areas
Xas part of the text segment.
X
XSaving them as text is good because it allows users to share more.
X
XHowever, on machines that locate the text area far from the data area,
Xthe boundary cannot feasibly be moved.  Such machines require
XNO_REMAP.
X
XAlso, remapping can cause trouble with the built-in startup routine
X/lib/crt0.o, which defines `environ' as an initialized variable.
XDumping `environ' as pure does not work!  So, to use remapping,
Xyou must write a startup routine for your machine in Emacs's crt0.c.
XIf NO_REMAP is defined, Emacs uses the system's crt0.o.
X
X* SECTION_ALIGNMENT
X
XSome machines that use COFF executables require that each section
Xstart on a certain boundary *in the COFF file*.  Such machines should
Xdefine SECTION_ALIGNMENT to a mask of the low-order bits that must be
Xzero on such a boundary.  This mask is used to control padding between
Xsegments in the COFF file.
X
XIf SECTION_ALIGNMENT is not defined, the segments are written
Xconsecutively with no attempt at alignment.  This is right for
Xunmodified system V.
X
X* SEGMENT_MASK
X
XSome machines require that the beginnings and ends of segments
X*in core* be on certain boundaries.  For most machines, a page
Xboundary is sufficient.  That is the default.  When a larger
Xboundary is needed, define SEGMENT_MASK to a mask of
Xthe bits that must be zero on such a boundary.
X
X* A_TEXT_OFFSET(HDR)
X
XSome machines count the a.out header as part of the size of the text
Xsegment (a_text); they may actually load the header into core as the
Xfirst data in the text segment.  Some have additional padding between
Xthe header and the real text of the program that is counted in a_text.
X
XFor these machines, define A_TEXT_OFFSET(HDR) to examine the header
Xstructure HDR and return the number of bytes to add to `a_text'
Xbefore writing it (above and beyond the number of bytes of actual
Xprogram text).  HDR's standard fields are already correct, except that
Xthis adjustment to the `a_text' field has not yet been made;
Xthus, the amount of offset can depend on the data in the file.
X  
X* A_TEXT_SEEK(HDR)
X
XIf defined, this macro specifies the number of bytes to seek into the
Xa.out file before starting to write the text segment.a
X
X* EXEC_MAGIC
X
XFor machines using COFF, this macro, if defined, is a value stored
Xinto the magic number field of the output file.
X
X* ADJUST_EXEC_HEADER
X
XThis macro can be used to generate statements to adjust or
Xinitialize nonstandard fields in the file header
X
X* ADDR_CORRECT(ADDR)
X
XMacro to correct an int which is the bit pattern of a pointer to a byte
Xinto an int which is the number of a byte.
X
XThis macro has a default definition which is usually right.
XThis default definition is a no-op on most machines (where a
Xpointer looks like an int) but not on all machines.
X
X*/
X
X#ifndef emacs
X#define PERROR(arg) perror (arg); return -1
X#else
X#include "config.h"
X#define PERROR(file) report_error (file, new)
X#endif
X
X#ifndef CANNOT_DUMP  /* all rest of file!  */
X
X#ifndef CANNOT_UNEXEC /* most of rest of file */
X
X#ifndef mips  /* mips machine requires completely separate code.  */
X
X#include <a.out.h>
X/* Define getpagesize () if the system does not.
X   Note that this may depend on symbols defined in a.out.h
X */
X#include "getpagesize.h"
X
X#ifndef makedev			/* Try to detect types.h already loaded */
X#include <sys/types.h>
X#endif
X#include <stdio.h>
X#include <sys/stat.h>
X#include <errno.h>
X
Xextern char *start_of_text ();		/* Start of text */
Xextern char *start_of_data ();		/* Start of initialized data */
X
X#ifdef COFF
X#ifndef USG
X#ifndef STRIDE
X#ifndef UMAX
X/* I have a suspicion that these are turned off on all systems
X   and can be deleted.  Try it in version 19.  */
X#include <machine/filehdr.h>
X#include <machine/opthdr.h>
X#include <machine/scnhdr.h>
X#include <machine/pte.h>
X#include <machine/symtab.h>
X#endif /* not UMAX */
X#endif /* Not STRIDE */
X#endif /* not USG */
Xstatic long block_copy_start;		/* Old executable start point */
Xstatic struct filehdr f_hdr;		/* File header */
Xstatic struct opthdr f_ohdr;		/* Optional file header (a.out) */
Xlong bias;			/* Bias to add for growth */
Xlong lnnoptr;			/* Pointer to line-number info within file */
X#define SYMS_START block_copy_start
X
Xstatic long text_scnptr;
Xstatic long data_scnptr;
X
X#else /* not COFF */
X
Xextern char *sbrk ();
X
X#define SYMS_START ((long) N_SYMOFF (ohdr))
X
X#ifdef HPUX
X#ifdef HP9000S200_ID
X#define MY_ID HP9000S200_ID
X#else
X#include <model.h>
X#define MY_ID MYSYS
X#endif /* no HP9000S200_ID */
Xstatic MAGIC OLDMAGIC = {MY_ID, SHARE_MAGIC};
Xstatic MAGIC NEWMAGIC = {MY_ID, DEMAND_MAGIC};
X#define N_TXTOFF(x) TEXT_OFFSET(x)
X#define N_SYMOFF(x) LESYM_OFFSET(x)
Xstatic struct exec hdr, ohdr;
X
X#else /* not HPUX */
X
X#if defined (USG) && !defined (IRIS)
Xstatic struct bhdr hdr, ohdr;
X#define a_magic fmagic
X#define a_text tsize
X#define a_data dsize
X#define a_bss bsize
X#define a_syms ssize
X#define a_trsize rtsize
X#define a_drsize rdsize
X#define a_entry entry
X#define	N_BADMAG(x) \
X    (((x).fmagic)!=OMAGIC && ((x).fmagic)!=NMAGIC &&\
X     ((x).fmagic)!=FMAGIC && ((x).fmagic)!=IMAGIC)
X#define NEWMAGIC FMAGIC
X#else /* IRIS or not USG */
Xstatic struct exec hdr, ohdr;
X#define NEWMAGIC ZMAGIC
X#endif /* IRIS or not USG */
X#endif /* not HPUX */
X
Xstatic int unexec_text_start;
Xstatic int unexec_data_start;
X
X#endif /* not COFF */
X
Xstatic int pagemask;
X
X/* Correct an int which is the bit pattern of a pointer to a byte
X   into an int which is the number of a byte.
X   This is a no-op on ordinary machines, but not on all.  */
X
X#ifndef ADDR_CORRECT   /* Let m-*.h files override this definition */
X#define ADDR_CORRECT(x) ((char *)(x) - (char*)0)
X#endif
X
X#ifdef emacs
X
Xstatic
Xreport_error (file, fd)
X     char *file;
X     int fd;
X{
X  if (fd)
X    close (fd);
X  error ("Failure operating on %s", file);
X}
X#endif /* emacs */
X
X#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1
X#define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1
X#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1
X
Xstatic
Xreport_error_1 (fd, msg, a1, a2)
X     int fd;
X     char *msg;
X     int a1, a2;
X{
X  close (fd);
X#ifdef emacs
X  error (msg, a1, a2);
X#else
X  fprintf (stderr, msg, a1, a2);
X  fprintf (stderr, "\n");
X#endif
X}
X
X/* ****************************************************************
X * unexec
X *
X * driving logic.
X */
Xunexec (new_name, a_name, data_start, bss_start, entry_address)
X     char *new_name, *a_name;
X     unsigned data_start, bss_start, entry_address;
X{
X  int new, a_out = -1;
X
X  if (a_name && (a_out = open (a_name, 0)) < 0)
X    {
X      PERROR (a_name);
X    }
X  if ((new = creat (new_name, 0666)) < 0)
X    {
X      PERROR (new_name);
X    }
X
X  if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0
X      || copy_text_and_data (new) < 0
X      || copy_sym (new, a_out, a_name, new_name) < 0
X#ifdef COFF
X      || adjust_lnnoptrs (new, a_out, new_name) < 0
X#endif
X      )
X    {
X      close (new);
X      /* unlink (new_name);	    	/* Failed, unlink new a.out */
X      return -1;	
X    }
X
X  close (new);
X  if (a_out >= 0)
X    close (a_out);
X  mark_x (new_name);
X  return 0;
X}
X
X/* ****************************************************************
X * make_hdr
X *
X * Make the header in the new a.out from the header in core.
X * Modify the text and data sizes.
X */
X#ifdef COFF
X struct scnhdr f_thdr;		/* Text section header */
X struct scnhdr f_dhdr;		/* Data section header */
X struct scnhdr f_bhdr;		/* Bss section header */
X struct scnhdr scntemp;		/* Temporary section header */
X#endif /* COFF */
Xstatic int
Xmake_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
X     int new, a_out;
X     unsigned data_start, bss_start, entry_address;
X     char *a_name;
X     char *new_name;
X{
X  int tem;
X  register int scns;
X  unsigned int bss_end;
X
X  pagemask = getpagesize () - 1;
X
X  /* Adjust text/data boundary. */
X#ifdef NO_REMAP
X  data_start = (int) start_of_data ();
X#else /* not NO_REMAP */
X  if (!data_start)
X    data_start = (int) start_of_data ();
X#endif /* not NO_REMAP */
X  data_start = ADDR_CORRECT (data_start);
X
X#ifdef SEGMENT_MASK
X  data_start = data_start & ~SEGMENT_MASK; /* (Down) to segment boundary. */
X#else
X  data_start = data_start & ~pagemask; /* (Down) to page boundary. */
X#endif
X
X  bss_end = (ADDR_CORRECT (sbrk (0)) + pagemask) & ~pagemask;
X
X  /* Adjust data/bss boundary. */
X  if (bss_start != 0)
X    {
X      bss_start = (ADDR_CORRECT (bss_start) + pagemask) & ~pagemask;	      /* (Up) to page bdry. */
X      if (bss_start > bss_end)
X	{
X	  ERROR1 ("unexec: Specified bss_start (%u) is past end of program",
X		  bss_start);
X	}
X    }
X  else
X    bss_start = bss_end;
X
X  if (data_start > bss_start)	/* Can't have negative data size. */
X    {
X      ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)",
X	      data_start, bss_start);
X    }
X
X#ifdef COFF
X  /* Salvage as much info from the existing file as possible */
X  if (a_out >= 0)
X    {
X      if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
X	{
X	  PERROR (a_name);
X	}
X      block_copy_start += sizeof (f_hdr);
X      if (f_hdr.h_opthdr > 0)
X	{
X	  if (read (a_out, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
X	    {
X	      PERROR (a_name);
X	    }
X	  block_copy_start += sizeof (f_ohdr);
X	}
X      /* Loop through section headers, copying them in */
X      for (scns = f_hdr.h_nscns; scns > 0; scns--) {
X	if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
X	  {
X	    PERROR (a_name);
X	  }
X	if (scntemp.s_scnptr > 0L)
X	  {
X            if (block_copy_start < scntemp.s_scnptr + scntemp.s_size)
X	      block_copy_start = scntemp.s_scnptr + scntemp.s_size;
X	  }
X	if (scntemp.s_flags & S_TEXT)
X	  {
X	    f_thdr = scntemp;
X	  }
X	else if (scntemp.s_flags & S_DATA)
X	  {
X	    f_dhdr = scntemp;
X	  }
X	else if (scntemp.s_flags & S_BSS)
X	  {
X	    f_bhdr = scntemp;
X	  }
X      }
X    }
X  else
X    {
X      ERROR0 ("can't build a COFF file from scratch yet");
X    }
X
X  /* Now we alter the contents of all the f_*hdr variables
X     to correspond to what we want to dump.  */
X
X  f_hdr.h_flags |= (0);      /* this isn't really correct..*/
X#ifdef EXEC_MAGIC
X  f_ohdr.magic = EXEC_MAGIC;
X#endif
X  f_thdr.s_vaddr = (long) start_of_text ();
X  f_thdr.s_size = data_start - f_thdr.s_vaddr;
X  f_thdr.s_scnptr = 4096;
X  f_thdr.s_relptr = 0;
X  f_thdr.s_nrel = 0;
X  f_thdr.s_prot = 0xA;
X
X  f_dhdr.s_vaddr = data_start;
X  f_dhdr.s_size = bss_start - data_start;
X  f_dhdr.s_scnptr = 4096 + (data_start - f_thdr.s_vaddr);
X  f_dhdr.s_relptr = 0;
X  f_dhdr.s_nrel = 0;
X  f_dhdr.s_prot = 0xC;
X  
X  f_bhdr.s_vaddr = bss_start;
X  f_bhdr.s_size = bss_end - bss_start + 4096 /* fudge */;
X  f_bhdr.s_scnptr = 0;
X  f_bhdr.s_relptr = 0;
X  f_bhdr.s_nrel = 0;
X  f_bhdr.s_prot = 0xC;
X#ifdef SECTION_ALIGNMENT
X  /* Some systems require special alignment
X     of the sections in the file itself.  */
X  f_thdr.s_scnptr
X    = (f_thdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT;
X#endif /* SECTION_ALIGNMENT */
X  text_scnptr = f_thdr.s_scnptr;
X  data_scnptr = f_dhdr.s_scnptr;
X  bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start;
X
X  if (f_ohdr.o_symptr > 0L)
X    {
X      f_ohdr.o_symptr += bias;
X    }
X
X  if (f_hdr.h_strptr > 0)
X  {
X      f_hdr.h_strptr += bias;
X  }
X
X#ifdef ADJUST_EXEC_HEADER
X  ADJUST_EXEC_HEADER
X#endif /* ADJUST_EXEC_HEADER */
X
X  if (write (new, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
X    {
X      PERROR (new_name);
X    }
X
X  if (write (new, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
X    {
X      PERROR (new_name);
X    }
X
X  if (write (new, &f_thdr, sizeof (f_thdr)) != sizeof (f_thdr))
X    {
X      PERROR (new_name);
X    }
X
X  if (write (new, &f_dhdr, sizeof (f_dhdr)) != sizeof (f_dhdr))
X    {
X      PERROR (new_name);
X    }
X
X  if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr))
X    {
X      PERROR (new_name);
X    }
X  return (0);
X
X#else /* if not COFF */
X
X  /* Get symbol table info from header of a.out file if given one. */
X  if (a_out >= 0)
X    {
X      if (read (a_out, &ohdr, sizeof hdr) != sizeof hdr)
X	{
X	  PERROR (a_name);
X	}
X
X      if N_BADMAG (ohdr)
X	{
X	  ERROR1 ("invalid magic number in %s", a_name);
X	}
X      hdr = ohdr;
X    }
X  else
X    {
X      bzero (hdr, sizeof hdr);
X    }
X
X  unexec_text_start = (long) start_of_text ();
X  unexec_data_start = data_start;
X
X  /* Machine-dependent fixup for header, or maybe for unexec_text_start */
X#ifdef ADJUST_EXEC_HEADER
X  ADJUST_EXEC_HEADER;
X#endif /* ADJUST_EXEC_HEADER */
X
X  hdr.a_trsize = 0;
X  hdr.a_drsize = 0;
X  if (entry_address != 0)
X    hdr.a_entry = entry_address;
X
X  hdr.a_bss = bss_end - bss_start;
X  hdr.a_data = bss_start - data_start;
X#ifdef NO_REMAP
X  hdr.a_text = ohdr.a_text;
X#else /* not NO_REMAP */
X  hdr.a_text = data_start - unexec_text_start;
X#endif /* not NO_REMAP */
X
X#ifdef A_TEXT_OFFSET
X  hdr.a_text += A_TEXT_OFFSET (ohdr);
X#endif
X
X  if (write (new, &hdr, sizeof hdr) != sizeof hdr)
X    {
X      PERROR (new_name);
X    }
X
X#ifdef A_TEXT_OFFSET
X  hdr.a_text -= A_TEXT_OFFSET (ohdr);
X#endif
X
X  return 0;
X
X#endif /* not COFF */
X}
X
X/* ****************************************************************
X * copy_text_and_data
X *
X * Copy the text and data segments from memory to the new a.out
X */
Xstatic int
Xcopy_text_and_data (new)
X     int new;
X{
X  register char *end;
X  register char *ptr;
X
X#ifdef COFF
X  lseek (new, (long) text_scnptr, 0);
X  ptr = (char *) f_thdr.s_vaddr;
X  end = ptr + f_thdr.s_size;
X  write_segment (new, ptr, end);
X
X  lseek (new, (long) data_scnptr, 0);
X  ptr = (char *) f_dhdr.s_vaddr;
X  end = ptr + f_dhdr.s_size;
X  write_segment (new, ptr, end);
X
X#else /* if not COFF */
X
X/* Some machines count the header as part of the text segment.
X   That is to say, the header appears in core
X   just before the address that start_of_text () returns.
X   For them, N_TXTOFF is the place where the header goes.
X   We must adjust the seek to the place after the header.
X   Note that at this point hdr.a_text does *not* count
X   the extra A_TEXT_OFFSET bytes, only the actual bytes of code.  */
X
X#ifdef A_TEXT_SEEK
X  lseek (new, (long) A_TEXT_SEEK (hdr), 0);
X#else
X#ifdef A_TEXT_OFFSET
X  /* Note that on the Sequent machine A_TEXT_OFFSET != sizeof (hdr)
X     and sizeof (hdr) is the correct amount to add here.  */
X  /* In version 19, eliminate this case and use A_TEXT_SEEK whenever
X     N_TXTOFF is not right.  */
X  lseek (new, (long) N_TXTOFF (hdr) + sizeof (hdr), 0);
X#else
X  lseek (new, (long) N_TXTOFF (hdr), 0);
X#endif /* no A_TEXT_OFFSET */
X#endif /* no A_TEXT_SEEK */
X
X  ptr = (char *) unexec_text_start;
X  end = ptr + hdr.a_text;
X  write_segment (new, ptr, end);
X
X  ptr = (char *) unexec_data_start;
X  end = ptr + hdr.a_data;
X/*  This lseek is certainly incorrect when A_TEXT_OFFSET
X    and I believe it is a no-op otherwise.
X    Let's see if its absence ever fails.  */
X/*  lseek (new, (long) N_TXTOFF (hdr) + hdr.a_text, 0); */
X  write_segment (new, ptr, end);
X
X#endif /* not COFF */
X
X  return 0;
X}
X
Xwrite_segment (new, ptr, end)
X     int new;
X     register char *ptr, *end;
X{
X  register int i, nwrite, ret;
X  char buf[80];
X  extern int errno;
X  char zeros[128];
X
X  bzero (zeros, sizeof zeros);
X
X  for (i = 0; ptr < end;)
X    {
X      /* distance to next multiple of 128.  */
X      nwrite = (((int) ptr + 128) & -128) - (int) ptr;
X      /* But not beyond specified end.  */
X      if (nwrite > end - ptr) nwrite = end - ptr;
X      ret = write (new, ptr, nwrite);
X      /* If write gets a page fault, it means we reached
X	 a gap between the old text segment and the old data segment.
X	 This gap has probably been remapped into part of the text segment.
X	 So write zeros for it.  */
X      if (ret == -1 && errno == EFAULT)
X	write (new, zeros, nwrite);
X      else if (nwrite != ret)
X	{
X	  sprintf (buf,
X		   "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
X		   ptr, new, nwrite, ret, errno);
X	  PERROR (buf);
X	}
X      i += nwrite;
X      ptr += nwrite;
X    }
X}
X
X/* ****************************************************************
X * copy_sym
X *
X * Copy the relocation information and symbol table from the a.out to the new
X */
Xstatic int
Xcopy_sym (new, a_out, a_name, new_name)
X     int new, a_out;
X     char *a_name, *new_name;
X{
X  char page[1024];
X  int n;
X
X  if (a_out < 0)
X    return 0;
X
X#ifdef COFF
X  if (SYMS_START == 0L)
X    return 0;
X#endif  /* COFF */
X
X#ifdef COFF
X  if (lnnoptr)			/* if there is line number info */
X    lseek (a_out, lnnoptr, 0);	/* start copying from there */
X  else
X#endif /* COFF */
X    lseek (a_out, SYMS_START, 0);	/* Position a.out to symtab. */
X
X  while ((n = read (a_out, page, sizeof page)) > 0)
X    {
X      if (write (new, page, n) != n)
X	{
X	  PERROR (new_name);
X	}
X    }
X  if (n < 0)
X    {
X      PERROR (a_name);
X    }
X  return 0;
X}
X
X/* ****************************************************************
X * mark_x
X *
X * After succesfully building the new a.out, mark it executable
X */
Xstatic
Xmark_x (name)
X     char *name;
X{
X  struct stat sbuf;
X  int um;
X  int new = 0;  /* for PERROR */
X
X  um = umask (777);
X  umask (um);
X  if (stat (name, &sbuf) == -1)
X    {
X      PERROR (name);
X    }
X  sbuf.st_mode |= 0111 & ~um;
X  if (chmod (name, sbuf.st_mode) == -1)
X    PERROR (name);
X}
X
X/*
X *	If the COFF file contains a symbol table and a line number section,
X *	then any auxiliary entries that have values for x_lnnoptr must
X *	be adjusted by the amount that the line number section has moved
X *	in the file (bias computed in make_hdr).  The #@$%&* designers of
X *	the auxiliary entry structures used the absolute file offsets for
X *	the line number entry rather than an offset from the start of the
X *	line number section!
X *
X *	When I figure out how to scan through the symbol table and pick out
X *	the auxiliary entries that need adjustment, this routine will
X *	be fixed.  As it is now, all such entries are wrong and sdb
X *	will complain.   Fred Fish, UniSoft Systems Inc.
X */
X
X#ifdef COFF
X
X/* This function is probably very slow.  Instead of reopening the new
X   file for input and output it should copy from the old to the new
X   using the two descriptors already open (WRITEDESC and READDESC).
X   Instead of reading one small structure at a time it should use
X   a reasonable size buffer.  But I don't have time to work on such
X   things, so I am installing it as submitted to me.  -- RMS.  */
X
Xadjust_lnnoptrs (writedesc, readdesc, new_name)
X     int writedesc;
X     int readdesc;
X     char *new_name;
X{
X#if 0
X  register int nsyms;
X  register int new;
X#ifdef amdahl_uts
X  SYMENT symentry;
X  AUXENT auxentry;
X#else
X  struct syment symentry;
X  struct auxent auxentry;
X#endif
X
X  if (!lnnoptr || !f_hdr.f_symptr)
X    return 0;
X
X  if ((new = open (new_name, 2)) < 0)
X    {
X      PERROR (new_name);
X      return -1;
X    }
X
X  lseek (new, f_hdr.f_symptr, 0);
X  for (nsyms = 0; nsyms < f_hdr.f_nsyms; nsyms++)
X    {
X      read (new, &symentry, SYMESZ);
X      if (symentry.n_numaux)
X	{
X	  read (new, &auxentry, AUXESZ);
X	  nsyms++;
X	  if (ISFCN (symentry.n_type)) {
X	    auxentry.x_sym.x_fcnary.x_fcn.x_lnnoptr += bias;
X	    lseek (new, -AUXESZ, 1);
X	    write (new, &auxentry, AUXESZ);
X	  }
X	}
X    }
X  close (new);
X#endif 0
X}
X
X#endif /* COFF */
X
X
X#else /* mips */
X
X/* Unexec for mips machines.
X   Note that I regard it as the responsibility of people at Mips
X   to tell me about any changes that need to be made in this code.
X   I won't take responsibility to think about it even if a change
X   I make elsewhere causes it to break.  -- RMS.  */
X
X#include <sys/types.h>
X#include <sys/file.h>
X#include <sys/stat.h>
X#include <stdio.h>
X#include <varargs.h>
X#include <filehdr.h>
X#include <aouthdr.h>
X#include <scnhdr.h>
X#include <sym.h>
X
X#define private static
X
Xextern int errno;
Xextern int sys_nerr;
Xextern char *sys_errlist[];
X#define EEOF -1
X
Xprivate void
Xfatal(s, va_alist)
X    va_dcl
X{
X    va_list ap;
X    if (errno == EEOF) {
X	fputs("unexec: unexpected end of file, ", stderr);
X    }
X    else if (errno < sys_nerr) {
X	fprintf(stderr, "unexec: %s, ", sys_errlist[errno]);
X    }
X    else {
X	fprintf(stderr, "unexec: error code %d, ", errno);
X    }
X    va_start(ap);
X    _doprnt(s, ap, stderr);
X    fputs(".\n", stderr);
X    exit(1);
X}
X
X#define READ(_fd, _buffer, _size, _error_message, _error_arg) \
X	errno = EEOF; \
X	if (read(_fd, _buffer, _size) != _size) \
X	  fatal(_error_message, _error_arg);
X
X#define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \
X	if (write(_fd, _buffer, _size) != _size) \
X	  fatal(_error_message, _error_arg);
X
X#define SEEK(_fd, _position, _error_message, _error_arg) \
X	errno = EEOF; \
X	if (lseek(_fd, _position, L_SET) != _position) \
X	  fatal(_error_message, _error_arg);
X
Xstruct headers {
X    struct filehdr fhdr;
X    struct aouthdr aout;
X    struct scnhdr text_section;
X    struct scnhdr rdata_section;
X    struct scnhdr data_section;
X    struct scnhdr sdata_section;
X    struct scnhdr sbss_section;
X    struct scnhdr bss_section;
X};
X
Xunexec (new_name, a_name, data_start, bss_start, entry_address)
X     char *new_name, *a_name;
X     unsigned data_start, bss_start, entry_address;
X{
X  int new, old;
X  int pagesize, brk;
X  int newsyms, symrel;
X  int nread;
X  struct headers hdr;
X#define BUFSIZE 8192
X  char buffer[BUFSIZE];
X
X  old = open (a_name, O_RDONLY, 0);
X  if (old < 0) fatal("openning %s", a_name);
X
X  new = creat (new_name, 0666);
X  if (new < 0) fatal("creating %s", new_name);
X
X  hdr = *((struct headers *)TEXT_START);
X  if (hdr.fhdr.f_magic != MIPSELMAGIC
X      && hdr.fhdr.f_magic != MIPSEBMAGIC) {
X      fprintf(stderr, "unexec: input file magic number is %x, not %x or %x.\n",
X	      hdr.fhdr.f_magic, MIPSELMAGIC, MIPSEBMAGIC);
X      exit(1);
X  }
X  if (hdr.fhdr.f_opthdr != sizeof(hdr.aout)) {
X      fprintf(stderr, "unexec: input a.out header is %d bytes, not %d.\n",
X	      hdr.fhdr.f_opthdr, sizeof(hdr.aout));
X      exit(1);
X  }
X#if 0
X  if (hdr.aout.magic != ZMAGIC
X      && hdr.aout.magic != NMAGIC
X      && hdr.aout.magic != OMAGIC) {
X      fprintf(stderr, "unexec: input file a.out magic number is %o, not %o, %o, or %o.\n",
X	      hdr.aout.magic, ZMAGIC, NMAGIC, OMAGIC);
X      exit(1);
X  }
X#else
X  if (hdr.aout.magic != ZMAGIC) {
X      fprintf(stderr, "unexec: input file a.out magic number is %o, not %o.\n",
X	      hdr.aout.magic, ZMAGIC);
X      exit(1);
X  }
X#endif
X  if (hdr.fhdr.f_nscns != 6) {
X      fprintf(stderr, "unexec: %d sections instead of 6.\n", hdr.fhdr.f_nscns);
X  }
X#define CHECK_SCNHDR(field, name, flags) \
X  if (strcmp(hdr.field.s_name, name) != 0) { \
X      fprintf(stderr, "unexec: %s section where %s expected.\n", \
X	      hdr.field.s_name, name); \
X      exit(1); \
X  } \
X  else if (hdr.field.s_flags != flags) { \
X      fprintf(stderr, "unexec: %x flags where %x expected in %s section.\n", \
X	      hdr.field.s_flags, flags, name); \
X  }
X  CHECK_SCNHDR(text_section,  _TEXT,  STYP_TEXT);
X  CHECK_SCNHDR(rdata_section, _RDATA, STYP_RDATA);
X  CHECK_SCNHDR(data_section,  _DATA,  STYP_DATA);
X  CHECK_SCNHDR(sdata_section, _SDATA, STYP_SDATA);
X  CHECK_SCNHDR(sbss_section,  _SBSS,  STYP_SBSS);
X  CHECK_SCNHDR(bss_section,   _BSS,   STYP_BSS);
X
X  pagesize = getpagesize();
X  brk = (sbrk(0) + pagesize - 1) & (-pagesize);
X  hdr.aout.dsize = brk - DATA_START;
X  hdr.aout.bsize = 0;
X  if (entry_address == 0) {
X    extern __start();
X    hdr.aout.entry = (unsigned)__start;
X  }
X  else {
X    hdr.aout.entry = entry_address;
X  }
X  hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
X  hdr.rdata_section.s_size = data_start - DATA_START;
X  hdr.data_section.s_vaddr = data_start;
X  hdr.data_section.s_paddr = data_start;
X  hdr.data_section.s_size = brk - DATA_START;
X  hdr.data_section.s_scnptr = hdr.rdata_section.s_scnptr
X				+ hdr.rdata_section.s_size;
X  hdr.sdata_section.s_vaddr = hdr.data_section.s_vaddr
X				+ hdr.data_section.s_size;
X  hdr.sdata_section.s_paddr = hdr.sdata_section.s_paddr;
X  hdr.sdata_section.s_size = 0;
X  hdr.sdata_section.s_scnptr = hdr.data_section.s_scnptr
X				+ hdr.data_section.s_size;
X  hdr.sbss_section.s_vaddr = hdr.sdata_section.s_vaddr
X				+ hdr.sdata_section.s_size;
X  hdr.sbss_section.s_paddr = hdr.sbss_section.s_vaddr;
X  hdr.sbss_section.s_size = 0;
X  hdr.sbss_section.s_scnptr = hdr.sdata_section.s_scnptr
X				+ hdr.sdata_section.s_size;
X  hdr.bss_section.s_vaddr = hdr.sbss_section.s_vaddr
X				+ hdr.sbss_section.s_size;
X  hdr.bss_section.s_paddr = hdr.bss_section.s_vaddr;
X  hdr.bss_section.s_size = 0;
X  hdr.bss_section.s_scnptr = hdr.sbss_section.s_scnptr
X				+ hdr.sbss_section.s_size;
X
X  WRITE(new, TEXT_START, hdr.aout.tsize,
X	"writing text section to %s", new_name);
X  WRITE(new, DATA_START, hdr.aout.dsize,
X	"writing text section to %s", new_name);
X
X  SEEK(old, hdr.fhdr.f_symptr, "seeking to start of symbols in %s", a_name);
X  errno = EEOF;
X  nread = read(old, buffer, BUFSIZE);
X  if (nread < sizeof(HDRR)) fatal("reading symbols from %s", a_name);
X#define symhdr ((pHDRR)buffer)
X  newsyms = hdr.aout.tsize + hdr.aout.dsize;
X  symrel = newsyms - hdr.fhdr.f_symptr;
X  hdr.fhdr.f_symptr = newsyms;
X  symhdr->cbLineOffset += symrel;
X  symhdr->cbDnOffset += symrel;
X  symhdr->cbPdOffset += symrel;
X  symhdr->cbSymOffset += symrel;
X  symhdr->cbOptOffset += symrel;
X  symhdr->cbAuxOffset += symrel;
X  symhdr->cbSsOffset += symrel;
X  symhdr->cbSsExtOffset += symrel;
X  symhdr->cbFdOffset += symrel;
X  symhdr->cbRfdOffset += symrel;
X  symhdr->cbExtOffset += symrel;
X#undef symhdr
X  do {
X      if (write(new, buffer, nread) != nread)
X	fatal("writing symbols to %s", new_name);
X      nread = read(old, buffer, BUFSIZE);
X      if (nread < 0) fatal("reading symbols from %s", a_name);
X#undef BUFSIZE
X  } while (nread != 0);
X
X  SEEK(new, 0, "seeking to start of header in %s", new_name);
X  WRITE(new, &hdr, sizeof(hdr),
X	"writing header of %s", new_name);
X
X  close(old);
X  close(new);
X  mark_x(new_name);
X}
X
X/*
X * mark_x
X *
X * After succesfully building the new a.out, mark it executable
X */
Xstatic
Xmark_x (name)
X     char *name;
X{
X  struct stat sbuf;
X  int um = umask (777);
X  umask (um);
X  if (stat(name, &sbuf) < 0)
X    fatal("getting protection on %s", name);
X  sbuf.st_mode |= 0111 & ~um;
X  if (chmod(name, sbuf.st_mode) < 0)
X    fatal("setting protection on %s", name);
X}
X
X#endif /* mips */
X
X#else /* CANNOT_UNEXEC */
X/* This is used by Apollo sysems running release 9.5
X   It is similar to the VMS code in vmsmap.c */
X
Xextern char * _malloc_base;
Xextern int my_edata;
X
X/* Structure to write into first block of map file. */
X
Xstruct map_data
X {
X   char * sdata;		/* Start of data area */
X   char * edata;		/* End of data area */
X   char * smalloc;		/* Start of malloc area */
X   char * emalloc;		/* End of malloc area */
X };
X
Xstatic int write_data ();
X
X/* Maps in the data and alloc area from the map file. */
X
Xint
Xmapin_data (name)
X     char * name;
X{
X  int fd;
X  struct map_data map_data;
X  char * sbrk ();
X  
X  _malloc_base = sbrk (0);
X
X  /* Open map file. */
X  if ((fd = open (name, O_RDONLY)) < 0)
X    {
X      printf ("Map file not available, running bare Emacs...\n");
X      return (0);		/* Map file not available */
X    }
X
X  /* Read the header data */
X  if (read (fd, &map_data, sizeof (map_data)) != sizeof (map_data))
X    {
X      printf ("Map file not correct format, running bare Emacs...\n");
X      return (0);		/* Map file not available */
X    }
X
X  if (map_data.sdata != start_of_data ())
X    {
X      printf ("Start of data area has moved: cannot map in data.\n");
X      return (0);
X    }
X  if (map_data.edata != (char *) &my_edata)
X    {
X      printf ("End of data area has moved: cannot map in data.\n");
X      return (0);
X    }
X  /* Extend virtual address space to end of previous malloc area. */
X  if (brk (map_data.emalloc))
X    {
X      printf ("Couldn't set brk.\n");
X      return (0);
X    }
X
X  /* Open the file for mapping now. */
X  if (read (fd, map_data.sdata, 1 + map_data.edata - map_data.sdata) < 0)
X    {
X      printf ("Couldn't read data section.\n");
X      exit (1);
X    }
X
X  /* Check mapping. */
X  if (_malloc_base != map_data.smalloc)
X    {
X      printf ("Data area mapping invalid.\n");
X      exit (1);
X    }
X  /* Map malloc area. */
X  if (read (fd, map_data.smalloc, 1 + map_data.emalloc - map_data.smalloc) < 0)
X    exit (1);
X
X  close (fd);
X
X  return (1);
X}
X
X/* Writes the data and alloc area to the map file. */
X
Xmapout_data (into)
X     char * into;
X{
X  int fd;
X  struct map_data map_data;
X  char * sbrk ();
X  
X  map_data.sdata = start_of_data ();
X  map_data.edata = (char *) &my_edata;
X  map_data.smalloc = _malloc_base;
X  map_data.emalloc = sbrk (0) - 1;
X  /* Create map file. */
X  fd = open (into, O_WRONLY | O_CREAT, 0666);
X  write (fd, &map_data, sizeof (map_data));
X  write (fd, map_data.sdata, 1+map_data.edata-map_data.sdata);
X  write (fd, map_data.smalloc, 1+map_data.emalloc-map_data.smalloc);
X  close (fd);
X  return (1);
X}
X
X#endif /* CANNOT_UNEXEC */
X
X#endif /* not CANNOT_DUMP */
E!O!F
newsize=`wc -c < unexec.c`
if [ $newsize -ne 35869 ]
then echo "File unexec.c was $newsize bytes, 35869 expected"
fi
echo 'x - m-convex.h (text)'
sed << 'E!O!F' 's/^X//' > m-convex.h
X/* m- file for convex C1.
X   Copyright (C) 1987 Free Software Foundation, Inc.
X
XThis file is part of GNU Emacs.
X
XGNU Emacs is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY.  No author or distributor
Xaccepts responsibility to anyone for the consequences of using it
Xor for whether it serves any particular purpose or works at all,
Xunless he says so in writing.  Refer to the GNU Emacs General Public
XLicense for full details.
X
XEveryone is granted permission to copy, modify and redistribute
XGNU Emacs, but only under the conditions described in the
XGNU Emacs General Public License.   A copy of this license is
Xsupposed to have been given to you along with GNU Emacs so you
Xcan know your rights and responsibilities.  It should be in a
Xfile named COPYING.  Among other things, the copyright notice
Xand this notice must be preserved on all copies.  */
X
X
X/* The following three symbols give information on
X the size of various data types.  */
X
X#define SHORTBITS 16		/* Number of bits in a short */
X
X#define INTBITS 32		/* Number of bits in an int */
X
X#define LONGBITS 32		/* Number of bits in a long */
X
X/* Define BIG_ENDIAN iff lowest-numbered byte in a word
X   is the most significant byte.  */
X
X#define BIG_ENDIAN
X
X/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
X * group of arguments and treat it as an array of the arguments.
X * Maybe it would be better to simply correct the code. */
X
X#define NO_ARG_ARRAY
X
X/* Define WORD_MACHINE if addresses and such have
X * to be corrected before they can be used as byte counts.  */
X
X/* #define WORD_MACHINE */
X
X/* Define how to take a char and sign-extend into an int.
X   On machines where char is signed, this is a no-op.  */
X
X#define SIGN_EXTEND_CHAR(c) (c)
X
X/* Now define a symbol for the cpu type, if your compiler
X   does not define it automatically.  */
X
X/* convex already defined... */
X
X/* Use type int rather than a union, to represent Lisp_Object */
X/* This is desirable for most machines.  */
X
X#define NO_UNION_TYPE
X
X/* crt0.c should use the vax-bsd style of entry, with no dummy args.  */
X
X#define CRT0_DUMMIES
X
X/* crt0.c should define a symbol `start' and do .globl with a dot.  */
X
X#define DOT_GLOBAL_START
X
X/* Data type of load average, as read out of kmem.  */
X
X#define LOAD_AVE_TYPE double
X
X/* Convert that into an integer that is 100 for a load average of 1.0  */
X
X#define LOAD_AVE_CVT(x) (int) ((x) * 100.0)
X
X/* Define CANNOT_DUMP on machines where unexec does not work.
X   Then the function dump-emacs will not be defined
X   and temacs will do (load "loadup") automatically unless told otherwise.  */
X
X/* #define CANNOT_DUMP */
X
X/* Define VIRT_ADDR_VARIES if the virtual addresses of
X   pure and impure space as loaded can vary, and even their
X   relative order cannot be relied on.
X
X   Otherwise Emacs assumes that text space precedes data space,
X   numerically.  */
X
X/*#define VIRT_ADDR_VARIES*/
X
X/* Define C_ALLOCA if this machine does not support a true alloca
X   and the one written in C should be used instead.
X   Define HAVE_ALLOCA to say that the system provides a properly
X   working alloca function and it should be used.
X   Define neither one if an assembler-language alloca
X   in the file alloca.s should be used.  */
X
X/*#define C_ALLOCA*/
X#define HAVE_ALLOCA
X
X/* Define NO_REMAP if memory segmentation makes it not work well
X   to change the boundary between the text section and data section
X   when Emacs is dumped.  If you define this, the preloaded Lisp
X   code will not be sharable; but that's better than failing completely.  */
X
X/* #define NO_REMAP */
X
X/* Addresses on the Convex have the high bit set.  */
X#define DATA_SEG_BITS (1 << (INTBITS-1))
X
X/* Right shift is logical shift.
X   And the usual way of handling such machines, which involves
X   copying the number into sign_extend_temp, does not work
X   for reasons as yet unknown.  */
X
X#define XINT(a)  sign_extend_lisp_int (a)
E!O!F
newsize=`wc -c < m-convex.h`
if [ $newsize -ne 3914 ]
then echo "File m-convex.h was $newsize bytes, 3914 expected"
fi
echo 'x - config.h (text)'
sed << 'E!O!F' 's/^X//' > config.h
X/* GNU Emacs site configuration template file.
X   Copyright (C) 1986 Free Software Foundation, Inc.
X
XThis file is part of GNU Emacs.
X
XGNU Emacs is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY.  No author or distributor
Xaccepts responsibility to anyone for the consequences of using it
Xor for whether it serves any particular purpose or works at all,
Xunless he says so in writing.  Refer to the GNU Emacs General Public
XLicense for full details.
X
XEveryone is granted permission to copy, modify and redistribute
XGNU Emacs, but only under the conditions described in the
XGNU Emacs General Public License.   A copy of this license is
Xsupposed to have been given to you along with GNU Emacs so you
Xcan know your rights and responsibilities.  It should be in a
Xfile named COPYING.  Among other things, the copyright notice
Xand this notice must be preserved on all copies.  */
X
X/* Include here a s- file that describes the system type you are using.
X   See the file ../etc/MACHINES for a list of systems and
X   the names of the s- files to use for them.
X   See s-template.h for documentation on writing s- files.  */
X#include "s-bsd4-3.h"
X 
X/* Include here a m- file that describes the machine and system you use.
X   See the file ../etc/MACHINES for a list of machines and
X   the names of the m- files to use for them.
X   See m-template.h for info on what m- files should define.
X   */
X#include "m-convex.h"
X#define COFF
X#define TEXT_START  0x80001000
X
X/* Load in the conversion definitions if this system
X   needs them and the source file being compiled has not
X   said to inhibit this.  */
X
X#ifdef SHORTNAMES
X#ifndef NO_SHORTNAMES
X#include "../shortnames/remap.h"
X#endif /* not NO_SHORTNAMES */
X#endif /* SHORTNAMES */
X
X/* define HAVE_X_WINDOWS if you want to use the X window system */
X
X#define HAVE_X_WINDOWS 
X#define X11
X
X/* define HAVE_X_MENU if you want to use the X window menu system.
X   This appears to work on some machines that support X
X   and not on others.  */
X
X/* #define HAVE_X_MENU */
X
X/* subprocesses should be defined if you want to
X have code for asynchronous subprocesses
X (as used in M-x compile and M-x shell).
X These do not work for some USG systems yet;
X for the ones where they work, the s-*.h file defines this flag.  */
X
X#ifndef VMS
X#ifndef USG
X#define subprocesses
X#endif
X#endif
X
X/* Define USER_FULL_NAME to return a string
X that is the user's full name.
X It can assume that the variable `pw'
X points to the password file entry for this user.
X
X At some sites, the pw_gecos field contains
X the user's full name.  If neither this nor any other
X field contains the right thing, use pw_name,
X giving the user's login name, since that is better than nothing.  */
X
X#define USER_FULL_NAME pw->pw_gecos
X
X/* Define AMPERSAND_FULL_NAME if you use the convention
X  that & in the full name stands for the login id.  */
X
X/* #define AMPERSAND_FULL_NAME */
X
X/* Maximum screen width we handle. */
X
X#define MScreenWidth 300
X
X/* Maximum screen length we handle. */
X
X#define MScreenLength 300
X
X/* # bytes of pure Lisp code to leave space for.
X  s-vms.h and m-sun2.h can override this default.  */
X
X#ifndef PURESIZE
X#ifdef HAVE_X_WINDOWS
X#define PURESIZE 132000
X#else
X#define PURESIZE 118000
X#endif
X#endif
X
X/* Define HIGHPRI as a negative number
X if you want Emacs to run at a higher than normal priority.
X For this to take effect, you must install it as setuid root. */
X
X/* #define HIGHPRI */
X
E!O!F
newsize=`wc -c < config.h`
if [ $newsize -ne 3426 ]
then echo "File config.h was $newsize bytes, 3426 expected"
fi
Skip Montanaro (montanaro@sprite.steinmetz.ge.com, montanaro@ge-crd.arpa)