diff mule-doc/NeXT.jp @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mule-doc/NeXT.jp	Mon Aug 13 09:02:59 2007 +0200
@@ -0,0 +1,914 @@
+This is an article posted to Mule mailing-list by Yoshiyuki Akiba.
+It describes what changes were necessary to install Mule on NeXT.
+Since the current Mule has already been patched for NeXT,
+all you have to do is (in config.h):
+#include <s-bsd4-3.h>
+#include <m-NeXT.h>
+
+============================================================
+Date: Fri, 12 Jun 92 10:22:51 JST
+From: akiba@cbs.canon.co.jp (Yoshiyuki Akiba)
+Return-Path: <akiba@cbs.canon.co.jp>
+To: mule@etl.go.jp
+In-Reply-To: Yoshiyuki Akiba's message of Thu, 4 Jun 92 10:00:35 JST <9206040100.AA17372@scarab.cbs.canon.co.jp>
+Subject: Patch for NeXT (Re: GNUS cause SEGV on NeXT)
+
+
+*$B$*$7$^$$$K(BNeXT$BMQ$N%Q%C%A(B(shar$B7A<0(B)$B$,$D$$$F$$$^$9(B*
+
+>>>>> akiba@cbs.canon.co.jp (Yoshiyuki Akiba) writes:
+akiba> $B:#=5$O$A$g$C$H!";~4V$,$H$l$^$;$s$,!"Mh=5Cf$K$OK\7o$NBP:v$b4^(B
+akiba> $B$a$F(BNeXT$BMQ%Q%C%A%-%C%H$r$*FO$1$G$-$k$H;W$$$^$9!#(B 
+
+NeXT$B>e$G(BGNUS$B$r5/F0$9$k$H(Bsegmentation fault$B$r5/$3$9860x$,(B
+$B$o$+$j$^$7$?!#0J2<$KD4$Y$?7k2L$r$^$H$a$F$*$-$^$9!#$*$7$^(B
+$B$$$K!"(Bmule$B$r(BNeXT$B>e$GF0$+$9$?$a$N%Q%C%A$r$D$1$F$*$-$^$9!#(B 
+
+$B%-%d%N%s3t<02q<R(B
+$B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?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%m!<%I%"%Y%l!<%8$r<h$j=P$;$k$N$G$3(B
+$B$l$r;HMQ$7$?(B(kmem$B%0%k!<%W$N%Q!<%_%C%7%g%s$NI,MW$J$7(B)$B!#(B
+m-NeXT.h$B$G(BLOAD_AVE_MACH$B$r(Bundef$B$9$l$P=>MhDL$jJ}K!$G%m!<%I(B
+$B%"%Y%l!<%8$r(B/dev/kmem$B$+$iFI$_$@$=$&$H$9$k!#(B 
+
+3)$B$J$I!"$I$&$G$b$$$$$3$H$G$9$,!":n$C$F$_$^$7$?!#(B
+LOAD_AVE_CVT()$B$b0l1~(B($B$*$=$i$/(B:-)$B@5$7$$Dj5A$K$7$F$"$j$^$9!#(B
+
+#!/bin/sh
+# This is a shell archive (produced by shar 3.49)
+# To extract the files from this archive, save it to a file, remove
+# everything above the "!/bin/sh" line above, and type "sh file_name".
+#
+# made 06/09/1992 00:49 UTC by akiba@scarab
+# Source directory /clients/UnderConstruction/mule-0.9.4/src
+#
+# existing files will NOT be overwritten unless -c is specified
+#
+# This shar contains:
+# length  mode       name
+# ------ ---------- ------------------------------------------
+#   2819 -rw-r--r-- m-NeXT.h
+#   8482 -rw-r--r-- unexNeXT.c
+#   5202 -rw-r--r-- patch-for-NeXT
+#
+# ============= m-NeXT.h ==============
+if test -f 'm-NeXT.h' -a X"$1" != X"-c"; then
+	echo 'x - skipping m-NeXT.h (File already exists)'
+else
+echo 'x - extracting m-NeXT.h (Text)'
+sed 's/^X//' << 'SHAR_EOF' > 'm-NeXT.h' &&
+/* Configuration file for the NeXT machine. */
+/*    Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+X
+This file is part of GNU Emacs.
+X
+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.
+X
+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.  */
+X
+X
+/* The following three symbols give information on
+X the size of various data types.  */
+X
+#define SHORTBITS 16		/* Number of bits in a short */
+X
+#define INTBITS 32		/* Number of bits in an int */
+X
+#define LONGBITS 32		/* Number of bits in a long */
+X
+/* 68000 has lowest-numbered byte as most significant */
+X
+#define BIG_ENDIAN
+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
+#define SIGN_EXTEND_CHAR(c) (c)
+X
+/* Say this machine is a 68000 */
+X
+#ifndef m68000
+#define m68000
+#endif
+X
+/* Use type int rather than a union, to represent Lisp_Object */
+X
+#define NO_UNION_TYPE
+X
+/* XINT must explicitly sign-extend */
+X
+#define EXPLICIT_SIGN_EXTEND
+X
+#define LIB_STANDARD -lsys_s
+X
+/* define LOAD_AVE_MACH, load average to be obtained from other than kmem */
+X
+#define LOAD_AVE_MACH
+X
+/* Data type of load average, as read out of kmem.  */
+X
+#define LOAD_AVE_TYPE long
+X
+/* Convert that into an integer that is 100 for a load average of 1.0  */
+#define	LSCALE	1000		/* defined in <sys/kernel.h> */
+#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / LSCALE)
+X
+/* KERNEL_FILE conflicts with some system header files */
+#undef	KERNEL_FILE
+#define	KERN_FILE "/mach"
+X
+#define environ _environ
+X
+#define NO_REMAP
+#define UNEXEC unexNeXT.o
+X
+/* not used in unexNeXT.c */
+#define TEXT_START 0 /* wrong: but nobody uses it anyway */
+#define TEXT_END get_etext()
+#define DATA_END get_edata()
+X
+#define HAVE_ALLOCA
+X
+#define SYSTEM_MALLOC
+X
+/* shoud be in s-mach.h */
+#define LD_SWITCH_SYSTEM -X -noseglinkedit
+#define C_SWITCH_SYSTEM -bsd
+X
+/* not to be included in ymakefile */
+#ifdef emacs
+#include <zone.h>
+extern NXZone *emacszone;
+#define malloc(size) NXZoneMalloc(emacszone,size)
+#define	realloc(ptr,size) NXZoneRealloc(emacszone,ptr,size)
+#define free(ptr) NXZoneFree(emacszone,ptr)
+#endif
+X
+/* quick hack */
+#define	READ_BUF_SIZE (1024*128)
+#define ZONESIZE 128
+SHAR_EOF
+chmod 0644 m-NeXT.h ||
+echo 'restore of m-NeXT.h failed'
+Wc_c="`wc -c < 'm-NeXT.h'`"
+test 2819 -eq "$Wc_c" ||
+	echo 'm-NeXT.h: original size 2819, current size' "$Wc_c"
+fi
+# ============= unexNeXT.c ==============
+if test -f 'unexNeXT.c' -a X"$1" != X"-c"; then
+	echo 'x - skipping unexNeXT.c (File already exists)'
+else
+echo 'x - extracting unexNeXT.c (Text)'
+sed 's/^X//' << 'SHAR_EOF' > 'unexNeXT.c' &&
+/*
+X * unexec for the NeXT Mach environment.
+X *
+X * Bradley Taylor (btaylor@NeXT.COM) 
+X * February 28, 1990
+X */
+#ifdef NeXT
+X
+#undef __STRICT_BSD__
+X
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <mach.h>
+#include <sys/loader.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <libc.h>
+X
+X
+extern struct section *getsectbyname(char *, char *);
+X
+/*
+X * Kludge: we don't expect any program data beyond VM_HIGHDATA
+X * What is really needed is a way to find out from malloc() which
+X * pages it vm_allocated and write only those out into the data segment.
+X *
+X * This kludge may break when we stop using fixed virtual address
+X * shared libraries. Actually, emacs will probably continue working, but be 
+X * much larger on disk than it needs to be (because non-malloced data will
+X * be in the file).
+X */
+static const unsigned VM_HIGHDATA = 0x2000000;
+X
+typedef struct region_t {
+X	vm_address_t address;
+X	vm_size_t size;
+X	vm_prot_t protection;
+X	vm_prot_t max_protection;
+X	vm_inherit_t inheritance;
+X	boolean_t shared;
+X	port_t object_name;
+X	vm_offset_t offset;
+} region_t;
+X
+X
+static void
+grow(
+X     struct load_command ***the_commands,
+X     unsigned *the_commands_len
+X     )
+{
+X	if (*the_commands == NULL) {
+X		*the_commands_len = 1;
+X		*the_commands = malloc(sizeof(*the_commands));
+X	} else {
+X		(*the_commands_len)++;
+X		*the_commands = realloc(*the_commands, 
+X					(*the_commands_len *
+X					 sizeof(**the_commands)));
+X	}
+}
+X
+X
+static void
+save_command(
+X	     struct load_command *command,
+X	     struct load_command ***the_commands,
+X	     unsigned *the_commands_len
+X	     )
+{
+X	struct load_command **tmp;
+X
+X	grow(the_commands, the_commands_len);
+X	tmp = &(*the_commands)[*the_commands_len - 1];
+X	*tmp = malloc(command->cmdsize);
+X	bcopy(command, *tmp, command->cmdsize);
+}
+X
+static void
+fatal_unexec(char *format, ...)
+{
+X	va_list ap;
+X
+X	va_start(ap, format);
+X	fprintf(stderr, "unexec: ");
+X	vfprintf(stderr, format, ap);
+X	fprintf(stderr, "\n");
+X	va_end(ap);
+}
+X
+static int
+read_macho(
+X	   int fd,
+X	   struct mach_header *the_header,
+X	   struct load_command ***the_commands,
+X	   unsigned *the_commands_len
+X	   )
+{
+X	struct load_command command;
+X	struct load_command *buf;
+X	int i;
+X	int size;
+X
+X	if (read(fd, the_header, sizeof(*the_header)) != sizeof(*the_header)) {
+X		fatal_unexec("cannot read macho header");
+X		return (0);
+X	}
+X	for (i = 0; i < the_header->ncmds; i++) {
+X		if (read(fd, &command, sizeof(struct load_command)) != 
+X		    sizeof(struct load_command)) {
+X		  	fatal_unexec("cannot read macho load command header");
+X			return (0);
+X		}
+X		size = command.cmdsize - sizeof(struct load_command);
+X		if (size < 0) {
+X		  	fatal_unexec("bogus load command size");
+X			return (0);
+X		}
+X		buf = malloc(command.cmdsize);
+X		buf->cmd = command.cmd;
+X		buf->cmdsize = command.cmdsize;
+X		if (read(fd, ((char *)buf + 
+X			      sizeof(struct load_command)), 
+X			 size) != size) {
+X		  	fatal_unexec("cannot read load command data");
+X			return (0);
+X		}
+X		save_command(buf, the_commands, the_commands_len);
+X	}
+X	return (1);
+}
+X
+static int
+filldatagap(
+X	    vm_address_t start_address,
+X	    vm_size_t *size,
+X	    vm_address_t end_address
+X	    )
+{
+X	vm_address_t address;
+X	vm_size_t gapsize;
+X
+X	address = (start_address + *size);
+X	gapsize = end_address - address;
+X	*size += gapsize;
+X	if (vm_allocate(task_self(), &address, gapsize,
+X			FALSE) != KERN_SUCCESS) {
+X		fatal_unexec("cannot vm_allocate");
+X	        return (0);
+X	}
+X	return (1);
+}
+X
+static int
+get_data_region(
+X		vm_address_t *address,
+X		vm_size_t *size
+X		)
+{
+X	region_t region;
+X	kern_return_t ret;
+X	struct section *sect;
+X
+X	sect = getsectbyname(SEG_DATA, SECT_DATA);
+X	region.address = 0;
+X	*address = 0;
+X	for (;;) {
+X		ret = vm_region(task_self(), 
+X				&region.address, 
+X				&region.size, 
+X				&region.protection, 
+X				&region.max_protection, 
+X				&region.inheritance,
+X				&region.shared, 
+X				&region.object_name, 
+X				&region.offset);
+X		if (ret != KERN_SUCCESS || region.address >= VM_HIGHDATA) {
+X			break;
+X		}
+X		if (*address != 0) {
+X			if (region.address > *address + *size) {
+X				if (!filldatagap(*address, size, 
+X						 region.address)) {
+X					return (0);
+X				}
+X			} 
+X			*size += region.size;
+X		} else {
+X			if (region.address == sect->addr) {
+X				*address = region.address;
+X				*size = region.size;
+X			} 
+X		}
+X		region.address += region.size;
+X	}
+X	return (1);
+}
+X
+static char *
+my_malloc(
+X	  vm_size_t size
+X	  )
+{
+X	vm_address_t address;
+X
+X	if (vm_allocate(task_self(), &address, size, TRUE) != KERN_SUCCESS) {
+X		return (NULL);
+X	}
+X	return ((char *)address);
+}
+X
+static void
+my_free(
+X	char *buf,
+X	vm_size_t size
+X	)
+{
+X	vm_deallocate(task_self(), (vm_address_t)buf, size);
+}
+X
+static int
+unexec_doit(
+X	    int infd,
+X	    int outfd
+X	    )
+{
+X	int i;
+X	struct load_command **the_commands = NULL;
+X	unsigned the_commands_len;
+X	struct mach_header the_header;
+X	int fgrowth;
+X	int fdatastart;
+X	int fdatasize;
+X	int size;
+X	struct stat st;
+X	char *buf;
+X	vm_address_t data_address;
+X	vm_size_t data_size;
+X
+X	struct segment_command *segment;
+X
+X	if (!read_macho(infd, &the_header, &the_commands, &the_commands_len)) {
+X		return (0);
+X	}
+X
+X
+X	{
+X	  extern int malloc_cookie;
+X	  malloc_cookie = malloc_freezedry();
+X	}
+X	if (!get_data_region(&data_address, &data_size)) {
+X		return (0);
+X	}
+X
+X
+X	/*
+X	 * DO NOT USE MALLOC IN THIS SECTION
+X	 */
+X	{
+X		/*
+X		 * Fix offsets
+X		 */
+X		for (i = 0; i < the_commands_len; i++) {
+X			switch (the_commands[i]->cmd) {
+X			case LC_SEGMENT:
+X				segment = ((struct segment_command *)
+X					   the_commands[i]);
+X				if (strcmp(segment->segname, SEG_DATA) == 0) {
+X					fdatastart = segment->fileoff;
+X					fdatasize = segment->filesize;
+X					fgrowth = (data_size - 
+X						   segment->filesize);
+X					segment->vmsize = data_size;
+X					segment->filesize = data_size;
+X				}
+X				break;
+X			case LC_SYMTAB:
+X				((struct symtab_command *)
+X				 the_commands[i])->symoff += fgrowth;
+X				((struct symtab_command *)
+X				 the_commands[i])->stroff += fgrowth;
+X				break;
+X			case LC_SYMSEG:
+X				((struct symseg_command *)
+X				 the_commands[i])->offset += fgrowth;
+X				break;
+X			default:
+X				break;
+X			}
+X		}
+X		
+X		/*
+X		 * Write header
+X		 */
+X		if (write(outfd, &the_header, 
+X			  sizeof(the_header)) != sizeof(the_header)) {
+X			fatal_unexec("cannot write output file");
+X			return (0);
+X		}
+X		
+X		/*
+X		 * Write commands
+X		 */
+X		for (i = 0; i < the_commands_len; i++) {
+X			if (write(outfd, the_commands[i], 
+X				  the_commands[i]->cmdsize) != 
+X			    the_commands[i]->cmdsize) {
+X			  	fatal_unexec("cannot write output file");
+X				return (0);
+X			}
+X		}
+X		
+X		/*
+X		 * Write original text
+X		 */
+X		if (lseek(infd, the_header.sizeofcmds + sizeof(the_header), 
+X			  L_SET) < 0) {
+X		  	fatal_unexec("cannot seek input file");
+X			return (0);
+X		}
+X		size = fdatastart - (sizeof(the_header) + 
+X				     the_header.sizeofcmds);
+X		buf = my_malloc(size);
+X		if (read(infd, buf, size) != size) {
+X			my_free(buf, size);
+X		  	fatal_unexec("cannot read input file");
+X		}
+X		if (write(outfd, buf, size) != size) {
+X			my_free(buf, size);
+X			fatal_unexec("cannot write output file");
+X			return (0);
+X		}
+X		my_free(buf, size);
+X		
+X		
+X		/*
+X		 * Write new data
+X		 */
+X		if (write(outfd, (char *)data_address, 
+X			  data_size) != data_size) {
+X			fatal_unexec("cannot write output file");
+X			return (0);
+X		}
+X		
+X	}
+X
+X	/*
+X	 * OKAY TO USE MALLOC NOW
+X	 */
+X
+X	/*
+X	 * Write rest of file
+X	 */
+X	fstat(infd, &st);
+X	if (lseek(infd, fdatasize, L_INCR) < 0) {
+X		fatal_unexec("cannot seek input file");
+X		return (0);
+X	}
+X	size = st.st_size - lseek(infd, 0, L_INCR);
+X
+X	buf = malloc(size);
+X	if (read(infd, buf, size) != size) {
+X		free(buf);
+X		fatal_unexec("cannot read input file");
+X		return (0);
+X	}
+X	if (write(outfd, buf, size) != size) {
+X		free(buf);
+X		fatal_unexec("cannot write output file");
+X		return (0);
+X	}
+X	free(buf);
+X	return (1);
+}
+X
+void
+unexec(
+X       char *outfile,
+X       char *infile
+X       )
+{
+X	int infd;
+X	int outfd;
+X	char tmpbuf[L_tmpnam];
+X	char *tmpfile;
+X
+X	infd = open(infile, O_RDONLY, 0);
+X	if (infd < 0) {
+X	  	fatal_unexec("cannot open input file `%s'", infile);
+X		exit(1);
+X	}
+X	
+X	tmpnam(tmpbuf);
+X	tmpfile = rindex(tmpbuf, '/');
+X	if (tmpfile == NULL) {
+X		tmpfile = tmpbuf;
+X	} else {
+X		tmpfile++;
+X	}
+X	outfd = open(tmpfile, O_WRONLY|O_TRUNC|O_CREAT, 0755);
+X	if (outfd < 0) {
+X		close(infd);
+X		fatal_unexec("cannot open tmp file `%s'", tmpfile);
+X		exit(1);
+X	}
+X	if (!unexec_doit(infd, outfd)) {
+X		close(infd);
+X		close(outfd);
+X		unlink(tmpfile);
+X		exit(1);
+X	}
+X	close(infd);
+X	close(outfd);
+X	if (rename(tmpfile, outfile) < 0) {
+X		unlink(tmpfile);
+X		fatal_unexec("cannot rename `%s' to `%s'", tmpfile, outfile);
+X		exit(1);
+X	}
+}
+#endif
+X
+SHAR_EOF
+chmod 0644 unexNeXT.c ||
+echo 'restore of unexNeXT.c failed'
+Wc_c="`wc -c < 'unexNeXT.c'`"
+test 8482 -eq "$Wc_c" ||
+	echo 'unexNeXT.c: original size 8482, current size' "$Wc_c"
+fi
+# ============= patch-for-NeXT ==============
+if test -f 'patch-for-NeXT' -a X"$1" != X"-c"; then
+	echo 'x - skipping patch-for-NeXT (File already exists)'
+else
+echo 'x - extracting patch-for-NeXT (Text)'
+sed 's/^X//' << 'SHAR_EOF' > 'patch-for-NeXT' &&
+diff -rc tmp/mule-0.9.4/src/emacs.c mule-0.9.4/src/emacs.c
+*** tmp/mule-0.9.4/src/emacs.c	Thu May 28 16:34:57 1992
+--- mule-0.9.4/src/emacs.c	Tue Jun  9 09:05:54 1992
+***************
+*** 229,234 ****
+--- 229,240 ----
+X  #endif /* LINK_CRTL_SHARE */
+X  #endif /* VMS */
+X  
++ #ifdef NeXT
++ #include <mach.h>
++ int malloc_cookie;
++ NXZone *emacszone;
++ #endif
++ 
+X  /* ARGSUSED */
+X  main (argc, argv, envp)
+X       int argc;
+***************
+*** 238,243 ****
+--- 244,260 ----
+X    int skip_args = 0;
+X    extern int errno;
+X    extern void malloc_warning ();
++ 
++ #ifdef NeXT
++   if (initialized) {
++     if (malloc_jumpstart(malloc_cookie) != 0)
++       fatal("malloc jumpstart failed!\n");
++   } else {
++     emacszone = NXCreateZone(ZONESIZE*vm_page_size,vm_page_size,1);
++     if(emacszone == NX_NOZONE)
++       fatal("can't create emacs zone.\n");
++   }
++ #endif
+X  
+X  /* Map in shared memory, if we are using that.  */
+X  #ifdef HAVE_SHM
+diff -rc tmp/mule-0.9.4/src/fileio.c mule-0.9.4/src/fileio.c
+*** tmp/mule-0.9.4/src/fileio.c	Thu May 28 16:34:58 1992
+--- mule-0.9.4/src/fileio.c	Mon Jun  8 18:48:52 1992
+***************
+*** 1586,1592 ****
+--- 1586,1594 ----
+X    close (XFASTINT (fd));
+X  }
+X  
++ #ifndef READ_BUF_SIZE
+X  #define READ_BUF_SIZE 1048576	/* 92.5.28 by K.Handa */
++ #endif
+X  
+X  DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
+X    1, 3, 0,
+diff -rc tmp/mule-0.9.4/src/fns.c mule-0.9.4/src/fns.c
+*** tmp/mule-0.9.4/src/fns.c	Thu May 28 16:29:46 1992
+--- mule-0.9.4/src/fns.c	Tue Jun  9 09:03:05 1992
+***************
+*** 1118,1123 ****
+--- 1118,1126 ----
+X      }
+X  }
+X  
++ #ifdef LOAD_AVE_MACH
++ #include <mach.h>
++ #else
+X  /* Avoid static vars inside a function since in HPUX they dump as pure.  */
+X  #ifdef DGUX
+X  static struct dg_sys_info_load_info load_info;  /* what-a-mouthful! */
+***************
+*** 1136,1141 ****
+--- 1139,1145 ----
+X  #define initialized ldav_initialized
+X  #define nl ldav_nl
+X  #endif /* Not DGUX */
++ #endif /* not LOAD_AVE_MACH */
+X  
+X  DEFUN ("load-average", Fload_average, Sload_average, 0, 0, 0,
+X    "Return the current 1 minute, 5 minute and 15 minute load averages\n\
+***************
+*** 1143,1148 ****
+--- 1147,1177 ----
+X  and then turned into integers).")
+X    ()
+X  {
++ #ifdef	LOAD_AVE_MACH
++    kern_return_t                    error;
++    host_t                           host;
++    unsigned int                     info_count;
++    struct processor_set_basic_info  info;
++    processor_set_t                  default_set;
++    
++    int load_ave = 0;
++ /* int mach_fac = 0; mach factor(not used)*/
++ 
++    error=processor_set_default(host_self(), &default_set);
++    if (error==KERN_SUCCESS){
++ 	info_count=PROCESSOR_SET_BASIC_INFO_COUNT;
++ 	error=processor_set_info(default_set, PROCESSOR_SET_BASIC_INFO,
++ 	   &host, (processor_set_info_t)&info, &info_count);
++ 	if (error == KERN_SUCCESS) {
++ 	   load_ave = (int)((float)info.load_average * 100.0 / LOAD_SCALE);
++ /*	   mach_fac = (int)((float)info.mach_factor  * 100.0 / LOAD_SCALE); */
++ 	}
++    }
++ 
++    return Fcons (make_number (load_ave),
++ 		Fcons (make_number (load_ave),
++ 		       Fcons (make_number (load_ave), Qnil)));
++ #else /* not LOAD_AVE_MACH */
+X  #ifdef DGUX
+X    /* perhaps there should be a "sys_load_avg" call in sysdep.c?! - DJB */
+X    load_info.one_minute     = 0.0;	/* just in case there is an error */
+***************
+*** 1225,1237 ****
+X        strcpy (nl[0].n_name, LDAV_SYMBOL);
+X        nl[1].n_zeroes = 0;
+X  #else /* NLIST_STRUCT */
+! #ifdef convex
+X        nl[0].n_un.n_name = LDAV_SYMBOL;
+X        nl[1].n_un.n_name = 0;
+! #else /* not convex */
+X        nl[0].n_name = LDAV_SYMBOL;
+X        nl[1].n_name = 0;
+! #endif /* not convex */
+X  #endif /* NLIST_STRUCT */
+X  
+X  #ifdef IRIS_4D
+--- 1254,1266 ----
+X        strcpy (nl[0].n_name, LDAV_SYMBOL);
+X        nl[1].n_zeroes = 0;
+X  #else /* NLIST_STRUCT */
+! #if defined(convex) || defined(NeXT)
+X        nl[0].n_un.n_name = LDAV_SYMBOL;
+X        nl[1].n_un.n_name = 0;
+! #else /* not convex, not NeXT */
+X        nl[0].n_name = LDAV_SYMBOL;
+X        nl[1].n_name = 0;
+! #endif /* not convex, not NeXT */
+X  #endif /* NLIST_STRUCT */
+X  
+X  #ifdef IRIS_4D
+***************
+*** 1242,1248 ****
+--- 1271,1281 ----
+X  	    nl[0].n_value &= 0x7fffffff;
+X  	}
+X  #else
++ #ifdef KERN_FILE
++       nlist (KERN_FILE, nl);
++ #else
+X        nlist (KERNEL_FILE, nl);
++ #endif
+X  #endif /* IRIS */
+X  
+X  #ifdef FIXUP_KERNEL_SYMBOL_ADDR
+***************
+*** 1288,1293 ****
+--- 1321,1327 ----
+X  			      Qnil)));
+X  #endif /* LOAD_AVE_TYPE */
+X  #endif /* not DGUX */
++ #endif /* not LOAD_AVE_MACH */
+X  }
+X  
+X  #undef channel
+diff -rc tmp/mule-0.9.4/src/lisp.h mule-0.9.4/src/lisp.h
+*** tmp/mule-0.9.4/src/lisp.h	Thu May 28 16:29:53 1992
+--- mule-0.9.4/src/lisp.h	Tue Jun  9 09:08:30 1992
+***************
+*** 1007,1013 ****
+X  
+X  extern void debugger ();
+X  
+! extern char *malloc (), *realloc (), *getenv (), *ctime (), *getwd ();
+X  extern long *xmalloc (), *xrealloc ();
+X  
+X  #ifdef MAINTAIN_ENVIRONMENT
+--- 1007,1016 ----
+X  
+X  extern void debugger ();
+X  
+! #ifndef malloc
+! extern char *malloc (), *realloc ();
+! #endif
+! extern char *getenv (), *ctime (), *getwd ();
+X  extern long *xmalloc (), *xrealloc ();
+X  
+X  #ifdef MAINTAIN_ENVIRONMENT
+SHAR_EOF
+chmod 0644 patch-for-NeXT ||
+echo 'restore of patch-for-NeXT failed'
+Wc_c="`wc -c < 'patch-for-NeXT'`"
+test 5202 -eq "$Wc_c" ||
+	echo 'patch-for-NeXT: original size 5202, current size' "$Wc_c"
+fi
+exit 0
+
+--
+$B%-%d%N%s3t<02q<R(B
+$B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?!<(B
+$B=)MU4nG7(B akiba@cbs.canon.co.jp
+
+============================================================
+Date: Mon, 15 Jun 92 10:20:23 JST
+From: akiba@cbs.canon.co.jp (Yoshiyuki Akiba)
+Return-Path: <akiba@cbs.canon.co.jp>
+To: mule@etl.go.jp
+In-Reply-To: Yoshiyuki Akiba's message of Fri, 12 Jun 92 10:22:51 JST <9206120122.AA19043@scarab.cbs.canon.co.jp>
+Subject: Re: Patch for NeXT
+
+
+*jserver$B$b(BNeXT$B>e$GF0$+$7$?$$J}$K(B*
+
+jserver$B$b(BNeXT$B>e$GF0$+$9$3$H$,$G$-$^$9$,!"(Bkill$B$9$k$H$-$K(B 
+PANIC $B$r5/$3$7$^$9!#860x$O!";HMQ$7$F$$$J$$%=%1%C%H$r(B
+shutdown()$B$7$F$$$k$?$a$G$9!#<!$N%Q%C%A$G2sHr$G$-$^$9!#(B 
+
+(Wnn 4.03$B$N;~$N%Q%C%A$J$N$G!"$=$N$^$^$G$O$"$?$i$J$$$+$b(B
+$BCN$l$^$;$s$,NL$,>/$J$$$N$G$3$l$G4*J[$7$F2<$5$$!#(B:-)
+
+diff -rcN Wnn/jserver/de.c wnn/jserver/de.c
+*** Wnn/jserver/de.c	Fri Aug 30 15:52:39 1991
+--- wnn/jserver/de.c	Fri Aug 30 17:26:14 1991
+***************
+*** 459,465 ****
+      shutdown(sock_d_in, 2);
+      close(sock_d_in);
+  
+!     for (fd = nofile; fd >= 0; fd--) {
+  	shutdown(fd, 2);
+  	close(fd);
+      }
+--- 470,477 ----
+      shutdown(sock_d_in, 2);
+      close(sock_d_in);
+  
+!     for (fd = nofile-1; fd >= 0; fd--) {
+!       if( (fd!=sock_d_in)&&(fd!=sock_d_un)&&sock_tst(all_socks, fd) )
+  	shutdown(fd, 2);
+  	close(fd);
+      }
+--
+$B%-%d%N%s3t<02q<R(B
+$B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?!<(B
+$B=)MU4nG7(B akiba@cbs.canon.co.jp
+