[gnu.emacs.bug] gnu-emacs port to ardent titan

mac@ardent.com (Michael McNamara) (06/23/89)

>  From: uunet!ai.mit.edu!rms
>  Date: Wed, 21 Jun 89 23:58:07 EDT
>  To: mac@ardent.com
>  Subject: gnu-emacs port to ardent titan
>  
>  Send bug reports, diffs, etc. to bug-gnu-emacs@prep.ai.mit.edu.
>  
>  
------------------

	Here are a set of diffs that support gnu-emacs on an Ardent
Titan, os release 2.0 & 2.1

*** dist-18.54/src/m-titan.h	Wed May 31 15:38:50 1989
--- titan-18.54/src/m-titan.h	Wed May 31 13:38:22 1989
***************
*** 0 ****
--- 1,164 ----
+ /* m- file for Ardent Titans.
+    Copyright (C) 1987 Free Software Foundation, Inc.
+ 
+ This file is part of GNU Emacs.
+ 
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY.  No author or distributor
+ accepts responsibility to anyone for the consequences of using it
+ or for whether it serves any particular purpose or works at all,
+ unless he says so in writing.  Refer to the GNU Emacs General Public
+ License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ GNU Emacs, but only under the conditions described in the
+ GNU Emacs General Public License.   A copy of this license is
+ supposed to have been given to you along with GNU Emacs so you
+ can know your rights and responsibilities.  It should be in a
+ file named COPYING.  Among other things, the copyright notice
+ and this notice must be preserved on all copies.  */
+ #ifdef  SYSTEM_TYPE
+ #undef  SYSTEM_TYPE
+ #define SYSTEM_TYPE "ardent-unix"
+ #endif
+ 
+ /* The following three symbols give information on
+  the size of various data types.  */
+ 
+ #define SHORTBITS 16		/* Number of bits in a short */
+ 
+ #define INTBITS 32		/* Number of bits in an int */
+ 
+ #define LONGBITS 32		/* Number of bits in a long */
+ 
+ /* Define BIG_ENDIAN iff lowest-numbered byte in a word
+    is the most significant byte.  */
+ 
+ #define BIG_ENDIAN
+ 
+ /* Define NO_ARG_ARRAY if you cannot take the address of the first of a
+  * group of arguments and treat it as an array of the arguments.  */
+ 
+ #define NO_ARG_ARRAY
+ 
+ /* Define WORD_MACHINE if addresses and such have
+  * to be corrected before they can be used as byte counts.  */
+ 
+ #undef WORD_MACHINE
+ 
+ /* Define how to take a char and sign-extend into an int.
+    On machines where char is signed, this is a no-op.  */
+ 
+ #define SIGN_EXTEND_CHAR(c) (c)
+ 
+ /* Now define a symbol for the cpu type, if your compiler
+    does not define it automatically:
+    Ones defined so far include vax, m68000, ns16000, pyramid,
+    orion, tahoe, APOLLO and many others */
+ 
+ #ifndef titan
+ #	define titan
+ #endif
+ 
+ /* Use type int rather than a union, to represent Lisp_Object */
+ /* This is desirable for most machines.  */
+ 
+ #define NO_UNION_TYPE
+ 
+ /* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
+    the 24-bit bit field into an int.  In other words, if bit fields
+    are always unsigned.
+ 
+    If you use NO_UNION_TYPE, this flag does not matter.  */
+ 
+ #define EXPLICIT_SIGN_EXTEND
+ 
+ /* Data type of load average, as read out of kmem.  */
+ 
+ #define LOAD_AVE_TYPE long
+ 
+ /* Convert that into an integer that is 100 for a load average of 1.0  */
+ 
+ #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100. / 65536.)
+ 
+ /* Define CANNOT_DUMP on machines where unexec does not work.
+    Then the function dump-emacs will not be defined
+    and temacs will do (load "loadup") automatically unless told otherwise.  */
+ 
+ /* #define CANNOT_DUMP */
+ 
+ /* Define VIRT_ADDR_VARIES if the virtual addresses of
+    pure and impure space as loaded can vary, and even their
+    relative order cannot be relied on.
+ 
+    Otherwise Emacs assumes that text space precedes data space,
+    numerically.  */
+ 
+ /* #define VIRT_ADDR_VARIES */
+ 
+ /* Define C_ALLOCA if this machine does not support a true alloca
+    and the one written in C should be used instead.
+    Define HAVE_ALLOCA to say that the system provides a properly
+    working alloca function and it should be used.
+    Define neither one if an assembler-language alloca
+    in the file alloca.s should be used.  */
+ 
+ #define C_ALLOCA
+ /* #define HAVE_ALLOCA */
+ 
+ /* Define NO_REMAP if memory segmentation makes it not work well
+    to change the boundary between the text section and data section
+    when Emacs is dumped.  If you define this, the preloaded Lisp
+    code will not be sharable; but that's better than failing completely.  */
+ 
+ #define NO_REMAP
+ 
+ /*
+  *	Define HAVE_TERMIO if the system provides sysV-style ioctls
+  *	for terminal control.
+  */
+ 
+ /* #define HAVE_TERMIO /* */
+ 
+ 
+ /* for unexec.c */
+ #define DATA_SECTION_ALIGNMENT pagemask
+ #define TEXT_START 0x400000
+ #define DATA_START 0x10003000
+ #define DATA_SEG_BITS 0x10000000
+ 
+ #define START_FILES /lib/crt0.o
+ #define C_OPTIMIZE_SWITCH -O1 
+ #define C_SWITCH_MACHINE -43 -I/usr/X11/include 
+ #define LD_SWITCH_MACHINE  -L -L/lib/bsd -L/usr/lib/bsd
+ #define COFF
+ /* No special debug library exists */
+ #define LIBS_DEBUG  
+ #define C_DEBUG_SWITCH -g
+ /* for loadst.c */
+ #undef KERNEL_FILE
+ #undef LDAV_SYMBOL
+ #define KERNEL_FILE "/unix"
+ #define LDAV_SYMBOL "avenrun"
+ #define NLIST_STRUCT
+ /* The standard definitions of these macros would work ok,
+    but these are faster because the constants are short.  */
+ 
+ #define XUINT(a) (((unsigned)(a) << INTBITS-VALBITS) >> INTBITS-VALBITS)
+ 
+ #define XSET(var, type, ptr) \
+    ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << INTBITS-VALBITS) >> INTBITS-VALBITS))
+ 
+ #define XSETINT(a, b)  XSET(a, XTYPE(a), b)
+ #define XSETUINT(a, b) XSET(a, XTYPE(a), b)
+ #define XSETPNTR(a, b) XSET(a, XTYPE(a), b)
+ 
+ #define XMARKBIT(a) ((a) < 0)
+ /*(a < 0) returns 1, not MARKBIT, so XSETMARKBIT has to be redefined.*/
+ #define XSETMARKBIT(a,b) ((a) = ((b) ? (a)|MARKBIT : (a) & ~MARKBIT))
+ #define XUNMARK(a) ((a) = (((a) << INTBITS-GCTYPEBITS-VALBITS) >> INTBITS-GCTYPEBITS-VALBITS))
+ #define PURESIZE 200000
+ #define HAVE_PTYS
+ #define MAINTAIN_ENVIRONMENT
+ #undef DKSTAT_HEADER_FILE
+ #define OBJECTS_MACHINE fsync.o
*** dist-18.54/src/fsync.s	Mon Jun 19 17:51:46 1989
--- titan-18.54/src/fsync.s	Mon Jun 19 18:04:14 1989
***************
*** 0 ****
--- 1,13 ----
+  # /* quick hack to fix broken mapping of fsync in bsd c library */
+  # /* mac@ardent */
+ 	.global _cerror
+ 	.global fsync
+ 	.text
+ fsync:
+ 	li	$v0,105
+ 	syscall
+ 	beq	$a3,$0,ok
+ 	j	_cerror
+ ok:
+ 	jr	$ra
+ 	.data
diff -cbr dist-18.54/etc/MACHINES titan-18.54/etc/MACHINES
*** dist-18.54/etc/MACHINES	Tue May 30 16:55:21 1989
--- titan-18.54/etc/MACHINES	Wed May 31 08:03:38 1989
***************
*** 131,136 ****
--- 131,142 ----
    Paraphrasing the statement should avoid the problem.
    I havenot yet received word as to the exact statement this is.
  
+ Ardent Titan (m-titan.h, s-bsd4-3.h)
+ 
+   18.54 works, with the supplied set of diffs. This machine is
+   native System V, but has extensive Bsd4-3 support, which was used
+   for the port.
+ 
  AT&T 3b2, 3b5, 3b15, 3b20 (m-att3b.h; s-usg5-2-2.h)
  
    Emacs will probably not work with certain kernel constants too small. 
diff -cbr dist-18.54/etc/Makefile titan-18.54/etc/Makefile
*** dist-18.54/etc/Makefile	Tue May 30 16:55:21 1989
--- titan-18.54/etc/Makefile	Tue May 30 10:45:08 1989
***************
*** 1,4 ****
! CFLAGS= -g
  # For Xenix.  Needed for movemail
  #  LOADLIBES= -lx
  # For Iris 4d.  Needed for loadst.
--- 1,4 ----
! CFLAGS= -g -43
  # For Xenix.  Needed for movemail
  #  LOADLIBES= -lx
  # For Iris 4d.  Needed for loadst.
diff -cbr dist-18.54/etc/loadst.c titan-18.54/etc/loadst.c
*** dist-18.54/etc/loadst.c	Tue May 30 16:55:24 1989
--- titan-18.54/etc/loadst.c	Wed May 31 08:15:03 1989
***************
*** 54,59 ****
--- 54,60 ----
  #else /* not USG */
  #include <sys/time.h>
  #ifdef LOAD_AVE_TYPE
+ #ifndef titan
  #ifndef RTU
  #ifndef UMAX
  #ifdef DKSTAT_HEADER_FILE
***************
*** 63,68 ****
--- 64,70 ----
  #endif /* not DKSTAT_HEADER_FILE */
  #endif /* UMAX */
  #endif /* not RTU */
+ #endif
  #endif /* LOAD_AVE_TYPE */
  #endif /* USG */
  
***************
*** 335,341 ****
--- 337,348 ----
      {
        LOAD_AVE_TYPE avenrun[3];
        avenrun[0] = 0;
+ #ifndef titan
        lseek (kmem, (long) nl[0].n_value, 0);
+ #else
+ #define K0_TO_PHYS(x)   ((unsigned)(x)&0x1FFFFFFF)      /* kseg0 to physical */
+       lseek(kmem, K0_TO_PHYS((long)nl[0].n_value), 0);
+ #endif 
        read (kmem, avenrun, sizeof (avenrun));
        return avenrun[0];
      }
diff -cbr dist-18.54/lisp/lpr.el titan-18.54/lisp/lpr.el
*** dist-18.54/lisp/lpr.el	Tue May 30 16:55:28 1989
--- titan-18.54/lisp/lpr.el	Wed May 31 11:50:17 1989
***************
*** 22,28 ****
  ;(defconst lpr-switches nil
  ;  "*List of strings to pass as extra switch args to lpr when it is invoked.")
  
! (defvar lpr-command (if (eq system-type 'usg-unix-v)
  			"lp" "lpr")
    "Shell command for printing a file")
  
--- 22,28 ----
  ;(defconst lpr-switches nil
  ;  "*List of strings to pass as extra switch args to lpr when it is invoked.")
  
! (defvar lpr-command (if (memq system-type '(usg-unix-v ardent-unix))
  			"lp" "lpr")
    "Shell command for printing a file")
  
diff -cbr dist-18.54/lisp/man.el titan-18.54/lisp/man.el
*** dist-18.54/lisp/man.el	Tue May 30 16:40:42 1989
--- titan-18.54/lisp/man.el	Wed May 31 11:50:28 1989
***************
*** 145,152 ****
--- 145,159 ----
  
  (defun insert-man-file (name)
    ;; Insert manual file (unpacked as necessary) into buffer
+   (if (eq system-type 'ardent-unix)
+       ;; Ardent keeps compressed files in /usr/man/cat?, but without a .Z
+       ;;  Grrrrr....
+       (if (equal (substring (file-name-directory name) -6 -2) "/cat")
+ 	  (call-process "zcat" name t nil )
+ 	(insert-file-contents name))
      (if (equal (substring name -2) ".Z")
  	(call-process "zcat" nil t nil name)
        (if (equal (substring name -2) ".z")
  	  (call-process "pcat" nil t nil name)
  	(insert-file-contents name))))
+ )
diff -cbr dist-18.54/lisp/paths.el titan-18.54/lisp/paths.el
*** dist-18.54/lisp/paths.el	Tue May 30 16:55:29 1989
--- titan-18.54/lisp/paths.el	Wed May 31 11:50:36 1989
***************
*** 54,60 ****
  
  (defconst rmail-spool-directory
    (if (memq system-type '(hpux usg-unix-v unisoft-unix rtu
! 			       silicon-graphics-unix))
        "/usr/mail/"
      "/usr/spool/mail/")
    "Name of directory used by system mailer for delivering new mail.
--- 54,60 ----
  
  (defconst rmail-spool-directory
    (if (memq system-type '(hpux usg-unix-v unisoft-unix rtu
! 			       silicon-graphics-unix ardent-unix))
        "/usr/mail/"
      "/usr/spool/mail/")
    "Name of directory used by system mailer for delivering new mail.
***************
*** 71,78 ****
  You may set this variable to nil in your `.emacs' file if you do not wish
  the terminal-initialization file to be loaded.")
  
! (defconst manual-program (if (eq system-type 'berkeley-unix)
! 			     "/usr/ucb/man" "/usr/bin/man")
    "Program to run to print man pages.")
  
  ;; Note that /usr/man/cat is not really right for this on sysV; nothing is,
--- 71,81 ----
  You may set this variable to nil in your `.emacs' file if you do not wish
  the terminal-initialization file to be loaded.")
  
! (defconst manual-program 
!   (cond
!    ((eq system-type 'berkeley-unix) "/usr/ucb/man" )
!    ((eq system-type 'ardent-unix) "/bin/man" ) 
!    (t "/usr/bin/man"))
    "Program to run to print man pages.")
  
  ;; Note that /usr/man/cat is not really right for this on sysV; nothing is,
***************
*** 102,107 ****
--- 105,115 ----
  	  '("/usr/man/cat.C" "/usr/man/cat.CP" "/usr/man/cat.CT"
  	    "/usr/man/cat.DOS/" "/usr/man/cat.F" "/usr/man/cat.HW"
  	    "/usr/man/cat.M/" "/usr/man/cat.S" "/usr/man/cat.LOCAL"))
+ 	 ((file-exists-p "/usr/man/bsd/cat1") ;; Ardent is riding the fence
+ 	  '("/usr/man/cat1" "/usr/man/cat2" "/usr/man/cat3"
+ 	    "/usr/man/bsd/cat1" "/usr/man/bsd/cat2" "/usr/man/bsd/cat3"
+ 	    "/usr/man/cat4" "/usr/man/cat5" "/usr/man/cat6"
+ 	    "/usr/man/cat7" "/usr/man/cat8" "/usr/man/catl" "/usr/man/catn"))
  	 ((file-exists-p "/usr/man/cat1")
  	  '("/usr/man/cat1" "/usr/man/cat2" "/usr/man/cat3"
  	    "/usr/man/cat4" "/usr/man/cat5" "/usr/man/cat6"
diff -cbr dist-18.54/src/callproc.c titan-18.54/src/callproc.c
*** dist-18.54/src/callproc.c	Tue May 30 16:55:39 1989
--- titan-18.54/src/callproc.c	Wed May 31 13:09:00 1989
***************
*** 373,382 ****
    close (out);
    close (err);
  
! #ifndef USG
    setpgrp (pid, pid);
-   setpgrp_of_tty (pid);
  #endif /* USG */
  
  #ifdef vipc
    something missing here;
--- 373,384 ----
    close (out);
    close (err);
  
! #ifdef USG
!   setpgrp ();			/* No arguments but equivalent in this case */
! #else
    setpgrp (pid, pid);
  #endif /* USG */
+   setpgrp_of_tty (pid);
  
  #ifdef vipc
    something missing here;
diff -cbr dist-18.54/src/cm.c titan-18.54/src/cm.c
*** dist-18.54/src/cm.c	Tue May 30 16:55:40 1989
--- titan-18.54/src/cm.c	Tue May 30 10:48:36 1989
***************
*** 200,209 ****
       * we will put into tabx (for ntabs) and tab2x (for n2tabs)).
       */
  
!     ntabs = (deltax + srcx % Wcm.cm_tabwidth) / Wcm.cm_tabwidth;
!     n2tabs = ntabs + 1;
!     tabx = (srcx / Wcm.cm_tabwidth + ntabs) * Wcm.cm_tabwidth;
!     tab2x = tabx + Wcm.cm_tabwidth;
  
      if (tab2x >= Wcm.cm_cols)	/* too far (past edge) */
  	n2tabs = 0;
--- 200,211 ----
       * we will put into tabx (for ntabs) and tab2x (for n2tabs)).
       */
  
!     n2tabs = 0;
!     tab2x = (srcx / Wcm.cm_tabwidth) * Wcm.cm_tabwidth;
!     while (tab2x <= dstx)
!       tab2x += Wcm.cm_tabwidth, n2tabs++;
!     ntabs = n2tabs - 1;
!     tabx = tab2x - Wcm.cm_tabwidth;
  
      if (tab2x >= Wcm.cm_cols)	/* too far (past edge) */
  	n2tabs = 0;
diff -cbr dist-18.54/src/lisp.h titan-18.54/src/lisp.h
*** dist-18.54/src/lisp.h	Tue May 30 16:42:43 1989
--- titan-18.54/src/lisp.h	Wed May 31 08:54:43 1989
***************
*** 288,294 ****
--- 288,300 ----
     and did not adjust it in that case.
     But I don't think that zero should ever be found
     in a Lisp object whose data type says it points to something.  */
+ #ifdef notthinking 
  #define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
+ #else /* now we are thinking */
+ /* zeros ARE found (especially when initializing pointers, like
+    in SetBfp() of buffer.c) - mac@ardent */
+ #define XPNTR(a) ((a) ? XUINT (a) | DATA_SEG_BITS : (a))
+ #endif
  #else
  #define XPNTR(a) XUINT (a)
  #endif
diff -cbr dist-18.54/src/malloc.c titan-18.54/src/malloc.c
*** dist-18.54/src/malloc.c	Tue May 30 16:55:49 1989
--- titan-18.54/src/malloc.c	Wed May 31 09:01:05 1989
***************
*** 144,149 ****
--- 144,150 ----
  #ifdef emacs
  /* config.h specifies which kind of system this is.  */
  #include "config.h"
+ #include <signal.h> /* needed for the blocking of SIGILL much later */
  #else
  
  /* Determine which kind of system this is.  */
***************
*** 167,173 ****
--- 168,176 ----
  
  #ifndef BSD4_2
  #ifndef USG
+ #ifndef titan 
  #include <sys/vlimit.h>		/* warn the user when near the end */
+ #endif /* titan */
  #endif /* not USG */
  #else /* if BSD4_2 */
  #include <sys/time.h>
***************
*** 322,328 ****
  #ifdef BSD
  #ifndef BSD4_1
    /* ?? There was a suggestion not to block SIGILL, somehow for GDB's sake.  */
!   oldmask = sigsetmask (-1);
  #endif
  #endif
  
--- 325,331 ----
  #ifdef BSD
  #ifndef BSD4_1
    /* ?? There was a suggestion not to block SIGILL, somehow for GDB's sake.  */
!   oldmask = sigsetmask (-1 & ~(1 << SIGILL)); /* Don't touch SIGILL.  Keeps gdb happy. */
  #endif
  #endif
  
***************
*** 771,777 ****
   *	data.  On USG systems this is the data space only.
   */
  
! #ifdef USG
  
  get_lim_data ()
  {
--- 774,780 ----
   *	data.  On USG systems this is the data space only.
   */
  
! #if defined(USG) || defined(titan) /* the titan is sysV at heart, so...*/
  
  get_lim_data ()
  {
***************
*** 786,792 ****
    lim_data -= (long) data_space_start;
  }
  
! #else /* not USG */
  #ifndef BSD4_2
  
  get_lim_data ()
--- 789,795 ----
    lim_data -= (long) data_space_start;
  }
  
! #else /* not USG or titan */
  #ifndef BSD4_2
  
  get_lim_data ()
diff -cbr dist-18.54/src/process.c titan-18.54/src/process.c
*** dist-18.54/src/process.c	Tue May 30 16:55:51 1989
--- titan-18.54/src/process.c	Wed May 31 09:07:56 1989
***************
*** 1,3 ****
--- 1,11 ----
+ /* Motorola changes to the standard distribution are marked with the CHANGES 
+    comment.  
+ 
+    Jan-12-89:  Fix to make /dev/tty work on subprocesses.  -- Marick
+ 
+ */
+ 
+ 
  /* Asynchronous subprocess control for GNU Emacs.
     Copyright (C) 1985, 1986, 1987, 1988 Free Software Foundation, Inc.
  
***************
*** 898,904 ****
  {
    int pid, inchannel, outchannel, forkin, forkout;
    int sv[2];
! #ifdef SIGCHLD
    int (*sigchld)();
  #endif
    register char *ptyname = 0;
--- 906,912 ----
  {
    int pid, inchannel, outchannel, forkin, forkout;
    int sv[2];
! #if defined SIGCHLD && defined USG
    int (*sigchld)();
  #endif
    register char *ptyname = 0;
***************
*** 919,933 ****
    outchannel = inchannel;
    if (ptyname)
      {
! #ifndef USG
!       /* On USG systems it does not work to open
  	 the pty's tty here and then close and reopen it in the child.  */
        forkout = forkin = open (ptyname, O_RDWR, 0);
        if (forkin < 0)
  	report_file_error ("Opening pty", Qnil);
! #else
!       forkin = forkout = -1;
! #endif
      }
    else
  #endif /* HAVE_PTYS */
--- 927,941 ----
    outchannel = inchannel;
    if (ptyname)
      {
! #if defined(IRIS) || defined(titan) || defined(USG)
!       /* On the IRIS system and the Ardent Titan it does not work to open
  	 the pty's tty here and then close and reopen it in the child.  */
+       forkin = forkout = -1;
+ #else
        forkout = forkin = open (ptyname, O_RDWR, 0);
        if (forkin < 0)
  	report_file_error ("Opening pty", Qnil);
! #endif /* IRIS, titan, USG */
      }
    else
  #endif /* HAVE_PTYS */
***************
*** 1014,1019 ****
--- 1022,1032 ----
  	   can do TIOCSPGRP only to the process's controlling tty. */
  	if (ptyname)
  	  {
+ 	      /* CHANGES:  In stock 18.52, this TIOCNOTTY wrapped the same 
+ 		 code as the HAVE_PTYS.  That broke (at least) Motorola
+ 		 System V machines.  Putting it here works for both Motorola
+ 		 and Gould (BSD-4.3-derived) machines.  Don't know about RTU
+ 		 or UNIPLUS. */
  	    /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? 
  	       I can't test it since I don't have 4.3.  */
  	    int j = open ("/dev/tty", O_RDWR, 0);
***************
*** 1112,1118 ****
        Lisp_Object name, buffer, host, service;
  {
    Lisp_Object proc;
-   register int i;
    struct sockaddr_in address;
    struct servent *svc_info;
    struct hostent *host_info;
--- 1125,1130 ----
***************
*** 1148,1155 ****
  
    if (connect (s, &address, sizeof address) == -1)
      {
!       close (s);
!       error ("Host \"%s\" not responding", XSTRING (host)->data);
      }
  
    inch = s;
--- 1160,1168 ----
  
    if (connect (s, &address, sizeof address) == -1)
      {
!       int xerrno = errno;
!       close(s);
!       error ("Attempt to connect to host \"%s\" failed: %s", XSTRING (host)->data,sys_errlist[xerrno]);
      }
  
    inch = s;
***************
*** 1286,1291 ****
--- 1299,1305 ----
    int Atemp;
    int wait_channel = 0;
    struct Lisp_Process *wait_proc = 0;
+   int tem;
    extern kbd_count;
  
    /* Detect when read_kbd is really the address of a Lisp_Process.  */
***************
*** 1309,1314 ****
--- 1323,1331 ----
        end_time += time_limit;
  #endif /* not HAVE_TIMEVAL */
      }
+ /* Moved this code to avoid Ardent compiler bug. */
+   tem = (wait_proc != 0 && (XFASTINT (wait_proc->flags) &
+ 			    PROC_STATUS) != RUNNING);
  
    while (1)
      {
***************
*** 1333,1340 ****
  	}
  
        /* Don't wait for output from a non-running process.  */
!       if (wait_proc != 0
! 	  && (XFASTINT (wait_proc->flags) & PROC_STATUS) != RUNNING)
  	break;
  
        if (fix_screen_hook)
--- 1350,1356 ----
  	}
  
        /* Don't wait for output from a non-running process.  */
!       if(tem)
  	break;
  
        if (fix_screen_hook)
***************
*** 1426,1431 ****
--- 1442,1456 ----
  	     I am guessing that this is the right response. -- RMS.  */
  	  else if (xerrno == EFAULT)
  	    Available = 0;
+ #endif
+ #ifdef titan
+ 	 /* If other end has died, we get an ENXIO.
+ 	    However, there may still be data to read.
+ 	    Available IS correct in this case, hence
+ 	    we just ignore ENXIO, and proceed.
+ 	     */
+ 	  else if (xerrno == ENXIO )
+ 		;
  #endif
  	  else if (xerrno == EBADF)
  	    abort ();
diff -cbr dist-18.54/src/sysdep.c titan-18.54/src/sysdep.c
*** dist-18.54/src/sysdep.c	Tue May 30 16:55:53 1989
--- titan-18.54/src/sysdep.c	Wed May 31 09:12:53 1989
***************
*** 1335,1341 ****
   *	Return the address of the end of the text segment prior to
   *	doing an unexec().  After unexec() the return value is undefined.
   */
!  
  char *
  end_of_text ()
  {
--- 1335,1341 ----
   *	Return the address of the end of the text segment prior to
   *	doing an unexec().  After unexec() the return value is undefined.
   */
! #ifndef titan  /* Don't need these */
  char *
  end_of_text ()
  {
***************
*** 1362,1368 ****
    return ((char *) &edata);
  #endif
  }
! 
  #endif /* not CANNOT_DUMP */
  
  /* Get_system_name returns as its value
--- 1362,1368 ----
    return ((char *) &edata);
  #endif
  }
! #endif /* !titan */
  #endif /* not CANNOT_DUMP */
  
  /* Get_system_name returns as its value
diff -cbr dist-18.54/src/unexec.c titan-18.54/src/unexec.c
*** dist-18.54/src/unexec.c	Tue May 30 16:43:02 1989
--- titan-18.54/src/unexec.c	Wed May 31 09:35:28 1989
***************
*** 149,154 ****
--- 149,161 ----
   * harpo!utah-cs!thomas, thomas@Utah-20
   *
   */
+ /* March 89 Michael McNamara (mac@ardent): finished Tim's port of unexec
+  * to the titan.
+ /* Aug 88 Tim Moore, Ardent Computer: Made many changes for the Ardent Titan.
+  * The Titan uses COFF format, but copies section headers into the text 
+  * segment; also, some changes are necessary to avoid reading and writing to
+  * the floating point hardware.
+  */
  
  /* There are several compilation parameters affecting unexec:
  
***************
*** 245,250 ****
--- 252,261 ----
  
  #ifndef CANNOT_UNEXEC /* most of rest of file */
  
+ #ifdef titan
+ #undef mips
+ #endif
+ 
  #include <a.out.h>
  /* Define getpagesize () if the system does not.
     Note that this may depend on symbols defined in a.out.h
***************
*** 266,271 ****
--- 277,283 ----
  #ifndef STRIDE
  #ifndef UMAX
  #ifndef sun386
+ #ifndef titan
  /* I have a suspicion that these are turned off on all systems
     and can be deleted.  Try it in version 19.  */
  #include <filehdr.h>
***************
*** 272,277 ****
--- 284,290 ----
  #include <aouthdr.h>
  #include <scnhdr.h>
  #include <syms.h>
+ #endif /* not titan */
  #endif /* not sun386 */
  #endif /* not UMAX */
  #endif /* Not STRIDE */
***************
*** 279,284 ****
--- 292,306 ----
  static long block_copy_start;		/* Old executable start point */
  static struct filehdr f_hdr;		/* File header */
  static struct aouthdr f_ohdr;		/* Optional file header (a.out) */
+ #ifdef titan
+ static struct scnhdr f_thdr;		/* Text section header */
+ static struct scnhdr f_dhdr;		/* Data section header */
+ static struct scnhdr f_shdr;		/* Symtab section header */
+ static struct scnhdr f_bhdr;		/* Bss section header */
+ static struct scnhdr f_ihdr;		/* Ident section header */
+ static struct scnhdr scntemp;		/* Temporary section header */
+ static long old_ident_scnptr;
+ #endif /* titan */
  long bias;			/* Bias to add for growth */
  long lnnoptr;			/* Pointer to line-number info within file */
  #define SYMS_START block_copy_start
***************
*** 285,290 ****
--- 307,315 ----
  
  static long text_scnptr;
  static long data_scnptr;
+ static long symtab_scnptr;
+ static long ident_scnptr;
+ static long symptr_scnptr;
  
  #else /* not COFF */
  
***************
*** 368,374 ****
  report_error_1 (fd, msg, a1, a2)
       int fd;
       char *msg;
!      int a1, a2;
  {
    close (fd);
  #ifdef emacs
--- 393,399 ----
  report_error_1 (fd, msg, a1, a2)
       int fd;
       char *msg;
!      unsigned int a1, a2;
  {
    close (fd);
  #ifdef emacs
***************
*** 388,394 ****
       char *new_name, *a_name;
       unsigned data_start, bss_start, entry_address;
  {
!   int new, a_out = -1;
  
    if (a_name && (a_out = open (a_name, 0)) < 0)
      {
--- 413,420 ----
       char *new_name, *a_name;
       unsigned data_start, bss_start, entry_address;
  {
!   int new = -1;
!   int a_out = -1;
  
    if (a_name && (a_out = open (a_name, 0)) < 0)
      {
***************
*** 403,410 ****
--- 429,438 ----
        || copy_text_and_data (new) < 0
        || copy_sym (new, a_out, a_name, new_name) < 0
  #ifdef COFF
+ #ifndef titan
        || adjust_lnnoptrs (new, a_out, new_name) < 0
  #endif
+ #endif
        )
      {
        close (new);
***************
*** 432,443 ****
       char *a_name;
       char *new_name;
  {
-   int tem;
  #ifdef COFF
    auto struct scnhdr f_thdr;		/* Text section header */
    auto struct scnhdr f_dhdr;		/* Data section header */
    auto struct scnhdr f_bhdr;		/* Bss section header */
    auto struct scnhdr scntemp;		/* Temporary section header */
    register int scns;
  #endif /* COFF */
    unsigned int bss_end;
--- 460,472 ----
       char *a_name;
       char *new_name;
  {
  #ifdef COFF
+ #ifndef titan 
    auto struct scnhdr f_thdr;		/* Text section header */
    auto struct scnhdr f_dhdr;		/* Data section header */
    auto struct scnhdr f_bhdr;		/* Bss section header */
    auto struct scnhdr scntemp;		/* Temporary section header */
+ #endif /* not titan */
    register int scns;
  #endif /* COFF */
    unsigned int bss_end;
***************
*** 515,520 ****
--- 544,553 ----
  	  {
  	    f_thdr = scntemp;
  	  }
+ 	else if (strcmp (scntemp.s_name, ".ident") == 0)
+ 	  {
+ 	    f_ihdr = scntemp;
+ 	  }
  	else if (strcmp (scntemp.s_name, ".data") == 0)
  	  {
  	    f_dhdr = scntemp;
***************
*** 523,530 ****
--- 556,567 ----
  	  {
  	    f_bhdr = scntemp;
  	  }
+ 	else if (strcmp (scntemp.s_name, ".symtab") == 0)
+ 	  {
+ 	    f_shdr = scntemp;
+ 	  }
        }
      }
    else
      {
        ERROR0 ("can't build a COFF file from scratch yet");
***************
*** 533,539 ****
    /* Now we alter the contents of all the f_*hdr variables
       to correspond to what we want to dump.  */
  
!   f_hdr.f_flags |= (F_RELFLG | F_EXEC);
  #ifdef EXEC_MAGIC
    f_ohdr.magic = EXEC_MAGIC;
  #endif
--- 570,580 ----
    /* Now we alter the contents of all the f_*hdr variables
       to correspond to what we want to dump.  */
  
!   f_hdr.f_flags |= (
! #ifndef titan
! 		    F_RELFLG | 
! #endif
! 		    F_EXEC);
  #ifdef EXEC_MAGIC
    f_ohdr.magic = EXEC_MAGIC;
  #endif
***************
*** 544,553 ****
--- 585,600 ----
  #endif /* NO_REMAP */
    f_ohdr.dsize = bss_start - f_ohdr.data_start;
    f_ohdr.bsize = bss_end - bss_start;
+ #ifndef titan /* not remapping; also, the text size in the file header */
+ 	      /* includes the headers; the text size in the text */
+ 	      /* header does not. */
    f_thdr.s_size = f_ohdr.tsize;
+ 
+ /* leave the text header where it is */
    f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr);
    f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr));
    lnnoptr = f_thdr.s_lnnoptr;
+ #endif /* not titan */
  #ifdef SECTION_ALIGNMENT
    /* Some systems require special alignment
       of the sections in the file itself.  */
***************
*** 572,581 ****
--- 619,651 ----
      = (f_dhdr.s_scnptr + DATA_SECTION_ALIGNMENT) & ~DATA_SECTION_ALIGNMENT;
  #endif /* DATA_SECTION_ALIGNMENT */
    data_scnptr = f_dhdr.s_scnptr;
+ #ifndef titan /* There's no explicit bss section on the titan. */
    f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize;
    f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize;
    f_bhdr.s_size = f_ohdr.bsize;
    f_bhdr.s_scnptr = 0L;
+ #endif /* titan */
+ #ifdef titan
+   ident_scnptr = f_ihdr.s_scnptr;
+   if (f_ihdr.s_scnptr > 0L)
+     {
+       f_ihdr.s_scnptr = f_dhdr.s_scnptr + f_dhdr.s_size;
+ #ifdef DATA_SECTION_ALIGNMENT
+       f_ihdr.s_scnptr = (f_ihdr.s_scnptr + DATA_SECTION_ALIGNMENT)
+ 	& ~DATA_SECTION_ALIGNMENT;
+ #endif
+     }
+   symtab_scnptr = f_shdr.s_scnptr;
+   if (f_shdr.s_scnptr > 0L) /* symbol section */
+     {
+       f_shdr.s_scnptr = f_ihdr.s_scnptr + f_ihdr.s_size;
+     }
+   symptr_scnptr = f_hdr.f_symptr;
+   if (f_hdr.f_symptr > 0L)
+     {
+       f_hdr.f_symptr = f_shdr.s_scnptr + f_shdr.s_size;
+     }
+ #else /* !titan  */
    bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start;
  
    if (f_hdr.f_symptr > 0L)
***************
*** 587,592 ****
--- 657,663 ----
      {
        f_thdr.s_lnnoptr += bias;
      }
+ #endif
  
  #ifdef ADJUST_EXEC_HEADER
    ADJUST_EXEC_HEADER
***************
*** 612,622 ****
--- 683,706 ----
        PERROR (new_name);
      }
  
+ #ifdef titan
+   if (write (new, &f_ihdr, sizeof (f_ihdr)) != sizeof (f_ihdr))
+     {
+       PERROR (new_name);
+     }
+ 
+   if (write (new, &f_shdr, sizeof (f_shdr)) != sizeof (f_shdr))
+     {
+       PERROR (new_name);
+     }
+ 
+ #else /* !titan */
    if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr))
      {
        PERROR (new_name);
      }
    return (0);
+ #endif /* !titan */
  
  #else /* if not COFF */
  
***************
*** 693,698 ****
--- 777,799 ----
  
  #ifdef COFF
    lseek (new, (long) text_scnptr, 0);
+ #ifdef titan 
+ /* The titan stores its headers in the text segment. Also, we have to
+    avoid reading the floating point stuff, which is located at the
+    beginning of the data segment. */
+   
+   ptr = (char *) f_thdr.s_vaddr;
+   end = ptr + f_thdr.s_size;
+   write_segment (new, ptr, end);
+   printf("copied text segment from [%x-%x] to xemacs\n", (int)ptr, (int)end);
+   lseek (new, (long) (data_scnptr + (DATA_START - f_ohdr.data_start)), 0);
+   printf("seeked to %x\n", (int)(data_scnptr + (DATA_START -
+ 					      f_ohdr.data_start)));
+   ptr = (char *)DATA_START;
+   end = ptr + f_ohdr.dsize;
+   write_segment (new, ptr, end);
+   printf("copied data segment from [%x-%x] to xemacs\n", (int)ptr, (int)end);
+ #else /* not titan */
    ptr = (char *) f_ohdr.text_start;
    end = ptr + f_ohdr.tsize;
    write_segment (new, ptr, end);
***************
*** 701,707 ****
    ptr = (char *) f_ohdr.data_start;
    end = ptr + f_ohdr.dsize;
    write_segment (new, ptr, end);
! 
  #else /* if not COFF */
  
  /* Some machines count the header as part of the text segment.
--- 802,808 ----
    ptr = (char *) f_ohdr.data_start;
    end = ptr + f_ohdr.dsize;
    write_segment (new, ptr, end);
! #endif /* not titan */
  #else /* if not COFF */
  
  /* Some machines count the header as part of the text segment.
***************
*** 789,796 ****
       int new, a_out;
       char *a_name, *new_name;
  {
!   char page[1024];
!   int n;
  
    if (a_out < 0)
      return 0;
--- 890,900 ----
       int new, a_out;
       char *a_name, *new_name;
  {
! #define SIZE 8192
!   char page[SIZE];
!   int n,newsyms,symrel;
!   char * ptr;
!   char * end;
  
    if (a_out < 0)
      return 0;
***************
*** 805,810 ****
--- 909,981 ----
      lseek (a_out, lnnoptr, 0);	/* start copying from there */
    else
  #endif /* COFF */
+ #ifdef titan
+ /* Copy .ident section */
+   lseek(a_out, ident_scnptr, 0);
+   printf( "seeking to 0x%x (start of .ident) in %s\n", 
+ 	 ident_scnptr,a_name);
+   lseek (new, (long) f_ihdr.s_scnptr, 0);
+   printf( "seeking to 0x%x (start of .ident) in %s\n", 
+ 	 f_ihdr.s_scnptr,new_name);
+   if ( (n = read(a_out, page, SIZE)) < 0)
+     PERROR("reading .ident section");
+   do
+     {
+       ptr = (char *) page;
+       end = ptr + n;
+       write_segment (new, ptr, end);
+       if( (n = read(a_out, page, SIZE)) < 0)
+ 	PERROR("reading .ident section");
+     } while (n != 0);  
+ /* Copy symtab section */
+   lseek(a_out, symtab_scnptr, 0);
+   printf( "seeking to 0x%x (start of .symtab) in %s\n", 
+ 	 symtab_scnptr,a_name);
+   lseek (new, (long) f_shdr.s_scnptr, 0);
+   printf( "seeking to 0x%x (start of .symtab) in %s\n", 
+ 	 f_shdr.s_scnptr,new_name);
+   if ( (n = read(a_out, page, SIZE)) < 0)
+     PERROR("reading .ident section");
+   do
+     {
+       ptr = (char *) page;
+       end = ptr + n;
+       write_segment (new, ptr, end);
+       if( (n = read(a_out, page, SIZE)) < 0)
+ 	PERROR("reading .ident section");
+     } while (n != 0);  
+ /* Copy & adjust symptr section */
+   lseek(a_out, symptr_scnptr, 0);
+   printf( "seeking to 0x%x (start of .symptr) in %s\n", 
+ 	 symptr_scnptr,a_name);
+   lseek (new, (long) f_hdr.f_symptr, 0);
+   printf( "seeking to 0x%x (start of .symptr) in %s\n", 
+ 	 f_hdr.f_symptr,new_name);
+   n = read(a_out, page, SIZE);
+   if (n < sizeof(SYMBOLS)) {
+ 	PERROR("reading symbols from temacs");
+   }
+ #define symhdr ((SYMBOLS *)page)
+   symrel = f_hdr.f_symptr - symptr_scnptr;
+   symhdr->strings_off += symrel;
+   if(symhdr->comini_off) /* If there is common initialized data...*/
+     symhdr->comini_off += symrel;
+   symhdr->address_off += symrel;
+   symhdr->symbols_off += symrel;
+ #undef symhdr
+   do
+     {
+       ptr = (char *) page;
+       end = ptr + n;
+       write_segment (new, ptr, end);
+       n = read(a_out, page, SIZE);
+       if (n < 0) {
+ 	PERROR("reading more symbols from temacs");
+       }
+ #undef SIZE
+     } while (n != 0);
+  
+ #else /* !titan */
      lseek (a_out, SYMS_START, 0);	/* Position a.out to symtab. */
  
    while ((n = read (a_out, page, sizeof page)) > 0)
***************
*** 818,823 ****
--- 989,995 ----
      {
        PERROR (a_name);
      }
+ #endif /* !titan */
    return 0;
  }
  
***************
*** 861,867 ****
   */
  
  #ifdef COFF
! 
  /* This function is probably very slow.  Instead of reopening the new
     file for input and output it should copy from the old to the new
     using the two descriptors already open (WRITEDESC and READDESC).
--- 1033,1039 ----
   */
  
  #ifdef COFF
! #ifndef titan 
  /* This function is probably very slow.  Instead of reopening the new
     file for input and output it should copy from the old to the new
     using the two descriptors already open (WRITEDESC and READDESC).
***************
*** 910,916 ****
      }
    close (new);
  }
! 
  #endif /* COFF */
  
  #endif /* not CANNOT_UNEXEC */
--- 1082,1088 ----
      }
    close (new);
  }
! #endif /* not titan */
  #endif /* COFF */
  
  #endif /* not CANNOT_UNEXEC */