70
|
1 This is an article posted to Mule mailing-list by Yoshiyuki Akiba.
|
|
2 It describes what changes were necessary to install Mule on NeXT.
|
|
3 Since the current Mule has already been patched for NeXT,
|
|
4 all you have to do is (in config.h):
|
|
5 #include <s-bsd4-3.h>
|
|
6 #include <m-NeXT.h>
|
|
7
|
|
8 ============================================================
|
|
9 Date: Fri, 12 Jun 92 10:22:51 JST
|
|
10 From: akiba@cbs.canon.co.jp (Yoshiyuki Akiba)
|
|
11 Return-Path: <akiba@cbs.canon.co.jp>
|
|
12 To: mule@etl.go.jp
|
|
13 In-Reply-To: Yoshiyuki Akiba's message of Thu, 4 Jun 92 10:00:35 JST <9206040100.AA17372@scarab.cbs.canon.co.jp>
|
|
14 Subject: Patch for NeXT (Re: GNUS cause SEGV on NeXT)
|
|
15
|
|
16
|
|
17 *$B$*$7$^$$$K(BNeXT$BMQ$N%Q%C%A(B(shar$B7A<0(B)$B$,$D$$$F$$$^$9(B*
|
|
18
|
|
19 >>>>> akiba@cbs.canon.co.jp (Yoshiyuki Akiba) writes:
|
|
20 akiba> $B:#=5$O$A$g$C$H!";~4V$,$H$l$^$;$s$,!"Mh=5Cf$K$OK\7o$NBP:v$b4^(B
|
|
21 akiba> $B$a$F(BNeXT$BMQ%Q%C%A%-%C%H$r$*FO$1$G$-$k$H;W$$$^$9!#(B
|
|
22
|
|
23 NeXT$B>e$G(BGNUS$B$r5/F0$9$k$H(Bsegmentation fault$B$r5/$3$9860x$,(B
|
|
24 $B$o$+$j$^$7$?!#0J2<$KD4$Y$?7k2L$r$^$H$a$F$*$-$^$9!#$*$7$^(B
|
|
25 $B$$$K!"(Bmule$B$r(BNeXT$B>e$GF0$+$9$?$a$N%Q%C%A$r$D$1$F$*$-$^$9!#(B
|
|
26
|
|
27 $B%-%d%N%s3t<02q<R(B
|
|
28 $B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?!<(B
|
|
29 $B=)MU4nG7(B akiba@cbs.canon.co.jp
|
|
30
|
|
31 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r(BNXZone{Mallo,Realloc,Free}$B$GCV$-49$($?(B
|
|
83
|
|
84 malloc$B4X?t72$N;HMQ$9$k%>!<%s$r(Bdump$B8e$K%j%9%H%"$G$-$J$$$?(B
|
|
85 $B$a@lMQ$N%>!<%s$r;HMQ$9$k$h$&$K$7$?(B
|
|
86
|
|
87 3) load-average$B$,@5$7$$CM$rJV$9$h$&$K$7$?(B
|
|
88
|
|
89 processor_set_info()$B$G%m!<%I%"%Y%l!<%8$r<h$j=P$;$k$N$G$3(B
|
|
90 $B$l$r;HMQ$7$?(B(kmem$B%0%k!<%W$N%Q!<%_%C%7%g%s$NI,MW$J$7(B)$B!#(B
|
|
91 m-NeXT.h$B$G(BLOAD_AVE_MACH$B$r(Bundef$B$9$l$P=>MhDL$jJ}K!$G%m!<%I(B
|
|
92 $B%"%Y%l!<%8$r(B/dev/kmem$B$+$iFI$_$@$=$&$H$9$k!#(B
|
|
93
|
|
94 3)$B$J$I!"$I$&$G$b$$$$$3$H$G$9$,!":n$C$F$_$^$7$?!#(B
|
|
95 LOAD_AVE_CVT()$B$b0l1~(B($B$*$=$i$/(B:-)$B@5$7$$Dj5A$K$7$F$"$j$^$9!#(B
|
|
96
|
|
97 #!/bin/sh
|
|
98 # This is a shell archive (produced by shar 3.49)
|
|
99 # To extract the files from this archive, save it to a file, remove
|
|
100 # everything above the "!/bin/sh" line above, and type "sh file_name".
|
|
101 #
|
|
102 # made 06/09/1992 00:49 UTC by akiba@scarab
|
|
103 # Source directory /clients/UnderConstruction/mule-0.9.4/src
|
|
104 #
|
|
105 # existing files will NOT be overwritten unless -c is specified
|
|
106 #
|
|
107 # This shar contains:
|
|
108 # length mode name
|
|
109 # ------ ---------- ------------------------------------------
|
|
110 # 2819 -rw-r--r-- m-NeXT.h
|
|
111 # 8482 -rw-r--r-- unexNeXT.c
|
|
112 # 5202 -rw-r--r-- patch-for-NeXT
|
|
113 #
|
|
114 # ============= m-NeXT.h ==============
|
|
115 if test -f 'm-NeXT.h' -a X"$1" != X"-c"; then
|
|
116 echo 'x - skipping m-NeXT.h (File already exists)'
|
|
117 else
|
|
118 echo 'x - extracting m-NeXT.h (Text)'
|
|
119 sed 's/^X//' << 'SHAR_EOF' > 'm-NeXT.h' &&
|
|
120 /* Configuration file for the NeXT machine. */
|
|
121 /* Copyright (C) 1985, 1986 Free Software Foundation, Inc.
|
|
122 X
|
|
123 This file is part of GNU Emacs.
|
|
124 X
|
|
125 GNU Emacs is distributed in the hope that it will be useful,
|
|
126 but WITHOUT ANY WARRANTY. No author or distributor
|
|
127 accepts responsibility to anyone for the consequences of using it
|
|
128 or for whether it serves any particular purpose or works at all,
|
|
129 unless he says so in writing. Refer to the GNU Emacs General Public
|
|
130 License for full details.
|
|
131 X
|
|
132 Everyone is granted permission to copy, modify and redistribute
|
|
133 GNU Emacs, but only under the conditions described in the
|
|
134 GNU Emacs General Public License. A copy of this license is
|
|
135 supposed to have been given to you along with GNU Emacs so you
|
|
136 can know your rights and responsibilities. It should be in a
|
|
137 file named COPYING. Among other things, the copyright notice
|
|
138 and this notice must be preserved on all copies. */
|
|
139 X
|
|
140 X
|
|
141 /* The following three symbols give information on
|
|
142 X the size of various data types. */
|
|
143 X
|
|
144 #define SHORTBITS 16 /* Number of bits in a short */
|
|
145 X
|
|
146 #define INTBITS 32 /* Number of bits in an int */
|
|
147 X
|
|
148 #define LONGBITS 32 /* Number of bits in a long */
|
|
149 X
|
|
150 /* 68000 has lowest-numbered byte as most significant */
|
|
151 X
|
|
152 #define BIG_ENDIAN
|
|
153 X
|
|
154 /* Define how to take a char and sign-extend into an int.
|
|
155 X On machines where char is signed, this is a no-op. */
|
|
156 X
|
|
157 #define SIGN_EXTEND_CHAR(c) (c)
|
|
158 X
|
|
159 /* Say this machine is a 68000 */
|
|
160 X
|
|
161 #ifndef m68000
|
|
162 #define m68000
|
|
163 #endif
|
|
164 X
|
|
165 /* Use type int rather than a union, to represent Lisp_Object */
|
|
166 X
|
|
167 #define NO_UNION_TYPE
|
|
168 X
|
|
169 /* XINT must explicitly sign-extend */
|
|
170 X
|
|
171 #define EXPLICIT_SIGN_EXTEND
|
|
172 X
|
|
173 #define LIB_STANDARD -lsys_s
|
|
174 X
|
|
175 /* define LOAD_AVE_MACH, load average to be obtained from other than kmem */
|
|
176 X
|
|
177 #define LOAD_AVE_MACH
|
|
178 X
|
|
179 /* Data type of load average, as read out of kmem. */
|
|
180 X
|
|
181 #define LOAD_AVE_TYPE long
|
|
182 X
|
|
183 /* Convert that into an integer that is 100 for a load average of 1.0 */
|
|
184 #define LSCALE 1000 /* defined in <sys/kernel.h> */
|
|
185 #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / LSCALE)
|
|
186 X
|
|
187 /* KERNEL_FILE conflicts with some system header files */
|
|
188 #undef KERNEL_FILE
|
|
189 #define KERN_FILE "/mach"
|
|
190 X
|
|
191 #define environ _environ
|
|
192 X
|
|
193 #define NO_REMAP
|
|
194 #define UNEXEC unexNeXT.o
|
|
195 X
|
|
196 /* not used in unexNeXT.c */
|
|
197 #define TEXT_START 0 /* wrong: but nobody uses it anyway */
|
|
198 #define TEXT_END get_etext()
|
|
199 #define DATA_END get_edata()
|
|
200 X
|
|
201 #define HAVE_ALLOCA
|
|
202 X
|
|
203 #define SYSTEM_MALLOC
|
|
204 X
|
|
205 /* shoud be in s-mach.h */
|
|
206 #define LD_SWITCH_SYSTEM -X -noseglinkedit
|
|
207 #define C_SWITCH_SYSTEM -bsd
|
|
208 X
|
|
209 /* not to be included in ymakefile */
|
|
210 #ifdef emacs
|
|
211 #include <zone.h>
|
|
212 extern NXZone *emacszone;
|
|
213 #define malloc(size) NXZoneMalloc(emacszone,size)
|
|
214 #define realloc(ptr,size) NXZoneRealloc(emacszone,ptr,size)
|
|
215 #define free(ptr) NXZoneFree(emacszone,ptr)
|
|
216 #endif
|
|
217 X
|
|
218 /* quick hack */
|
|
219 #define READ_BUF_SIZE (1024*128)
|
|
220 #define ZONESIZE 128
|
|
221 SHAR_EOF
|
|
222 chmod 0644 m-NeXT.h ||
|
|
223 echo 'restore of m-NeXT.h failed'
|
|
224 Wc_c="`wc -c < 'm-NeXT.h'`"
|
|
225 test 2819 -eq "$Wc_c" ||
|
|
226 echo 'm-NeXT.h: original size 2819, current size' "$Wc_c"
|
|
227 fi
|
|
228 # ============= unexNeXT.c ==============
|
|
229 if test -f 'unexNeXT.c' -a X"$1" != X"-c"; then
|
|
230 echo 'x - skipping unexNeXT.c (File already exists)'
|
|
231 else
|
|
232 echo 'x - extracting unexNeXT.c (Text)'
|
|
233 sed 's/^X//' << 'SHAR_EOF' > 'unexNeXT.c' &&
|
|
234 /*
|
|
235 X * unexec for the NeXT Mach environment.
|
|
236 X *
|
|
237 X * Bradley Taylor (btaylor@NeXT.COM)
|
|
238 X * February 28, 1990
|
|
239 X */
|
|
240 #ifdef NeXT
|
|
241 X
|
|
242 #undef __STRICT_BSD__
|
|
243 X
|
|
244 #include <stdio.h>
|
|
245 #include <stdlib.h>
|
|
246 #include <stdarg.h>
|
|
247 #include <mach.h>
|
|
248 #include <sys/loader.h>
|
|
249 #include <sys/file.h>
|
|
250 #include <sys/stat.h>
|
|
251 #include <libc.h>
|
|
252 X
|
|
253 X
|
|
254 extern struct section *getsectbyname(char *, char *);
|
|
255 X
|
|
256 /*
|
|
257 X * Kludge: we don't expect any program data beyond VM_HIGHDATA
|
|
258 X * What is really needed is a way to find out from malloc() which
|
|
259 X * pages it vm_allocated and write only those out into the data segment.
|
|
260 X *
|
|
261 X * This kludge may break when we stop using fixed virtual address
|
|
262 X * shared libraries. Actually, emacs will probably continue working, but be
|
|
263 X * much larger on disk than it needs to be (because non-malloced data will
|
|
264 X * be in the file).
|
|
265 X */
|
|
266 static const unsigned VM_HIGHDATA = 0x2000000;
|
|
267 X
|
|
268 typedef struct region_t {
|
|
269 X vm_address_t address;
|
|
270 X vm_size_t size;
|
|
271 X vm_prot_t protection;
|
|
272 X vm_prot_t max_protection;
|
|
273 X vm_inherit_t inheritance;
|
|
274 X boolean_t shared;
|
|
275 X port_t object_name;
|
|
276 X vm_offset_t offset;
|
|
277 } region_t;
|
|
278 X
|
|
279 X
|
|
280 static void
|
|
281 grow(
|
|
282 X struct load_command ***the_commands,
|
|
283 X unsigned *the_commands_len
|
|
284 X )
|
|
285 {
|
|
286 X if (*the_commands == NULL) {
|
|
287 X *the_commands_len = 1;
|
|
288 X *the_commands = malloc(sizeof(*the_commands));
|
|
289 X } else {
|
|
290 X (*the_commands_len)++;
|
|
291 X *the_commands = realloc(*the_commands,
|
|
292 X (*the_commands_len *
|
|
293 X sizeof(**the_commands)));
|
|
294 X }
|
|
295 }
|
|
296 X
|
|
297 X
|
|
298 static void
|
|
299 save_command(
|
|
300 X struct load_command *command,
|
|
301 X struct load_command ***the_commands,
|
|
302 X unsigned *the_commands_len
|
|
303 X )
|
|
304 {
|
|
305 X struct load_command **tmp;
|
|
306 X
|
|
307 X grow(the_commands, the_commands_len);
|
|
308 X tmp = &(*the_commands)[*the_commands_len - 1];
|
|
309 X *tmp = malloc(command->cmdsize);
|
|
310 X bcopy(command, *tmp, command->cmdsize);
|
|
311 }
|
|
312 X
|
|
313 static void
|
|
314 fatal_unexec(char *format, ...)
|
|
315 {
|
|
316 X va_list ap;
|
|
317 X
|
|
318 X va_start(ap, format);
|
|
319 X fprintf(stderr, "unexec: ");
|
|
320 X vfprintf(stderr, format, ap);
|
|
321 X fprintf(stderr, "\n");
|
|
322 X va_end(ap);
|
|
323 }
|
|
324 X
|
|
325 static int
|
|
326 read_macho(
|
|
327 X int fd,
|
|
328 X struct mach_header *the_header,
|
|
329 X struct load_command ***the_commands,
|
|
330 X unsigned *the_commands_len
|
|
331 X )
|
|
332 {
|
|
333 X struct load_command command;
|
|
334 X struct load_command *buf;
|
|
335 X int i;
|
|
336 X int size;
|
|
337 X
|
|
338 X if (read(fd, the_header, sizeof(*the_header)) != sizeof(*the_header)) {
|
|
339 X fatal_unexec("cannot read macho header");
|
|
340 X return (0);
|
|
341 X }
|
|
342 X for (i = 0; i < the_header->ncmds; i++) {
|
|
343 X if (read(fd, &command, sizeof(struct load_command)) !=
|
|
344 X sizeof(struct load_command)) {
|
|
345 X fatal_unexec("cannot read macho load command header");
|
|
346 X return (0);
|
|
347 X }
|
|
348 X size = command.cmdsize - sizeof(struct load_command);
|
|
349 X if (size < 0) {
|
|
350 X fatal_unexec("bogus load command size");
|
|
351 X return (0);
|
|
352 X }
|
|
353 X buf = malloc(command.cmdsize);
|
|
354 X buf->cmd = command.cmd;
|
|
355 X buf->cmdsize = command.cmdsize;
|
|
356 X if (read(fd, ((char *)buf +
|
|
357 X sizeof(struct load_command)),
|
|
358 X size) != size) {
|
|
359 X fatal_unexec("cannot read load command data");
|
|
360 X return (0);
|
|
361 X }
|
|
362 X save_command(buf, the_commands, the_commands_len);
|
|
363 X }
|
|
364 X return (1);
|
|
365 }
|
|
366 X
|
|
367 static int
|
|
368 filldatagap(
|
|
369 X vm_address_t start_address,
|
|
370 X vm_size_t *size,
|
|
371 X vm_address_t end_address
|
|
372 X )
|
|
373 {
|
|
374 X vm_address_t address;
|
|
375 X vm_size_t gapsize;
|
|
376 X
|
|
377 X address = (start_address + *size);
|
|
378 X gapsize = end_address - address;
|
|
379 X *size += gapsize;
|
|
380 X if (vm_allocate(task_self(), &address, gapsize,
|
|
381 X FALSE) != KERN_SUCCESS) {
|
|
382 X fatal_unexec("cannot vm_allocate");
|
|
383 X return (0);
|
|
384 X }
|
|
385 X return (1);
|
|
386 }
|
|
387 X
|
|
388 static int
|
|
389 get_data_region(
|
|
390 X vm_address_t *address,
|
|
391 X vm_size_t *size
|
|
392 X )
|
|
393 {
|
|
394 X region_t region;
|
|
395 X kern_return_t ret;
|
|
396 X struct section *sect;
|
|
397 X
|
|
398 X sect = getsectbyname(SEG_DATA, SECT_DATA);
|
|
399 X region.address = 0;
|
|
400 X *address = 0;
|
|
401 X for (;;) {
|
|
402 X ret = vm_region(task_self(),
|
|
403 X ®ion.address,
|
|
404 X ®ion.size,
|
|
405 X ®ion.protection,
|
|
406 X ®ion.max_protection,
|
|
407 X ®ion.inheritance,
|
|
408 X ®ion.shared,
|
|
409 X ®ion.object_name,
|
|
410 X ®ion.offset);
|
|
411 X if (ret != KERN_SUCCESS || region.address >= VM_HIGHDATA) {
|
|
412 X break;
|
|
413 X }
|
|
414 X if (*address != 0) {
|
|
415 X if (region.address > *address + *size) {
|
|
416 X if (!filldatagap(*address, size,
|
|
417 X region.address)) {
|
|
418 X return (0);
|
|
419 X }
|
|
420 X }
|
|
421 X *size += region.size;
|
|
422 X } else {
|
|
423 X if (region.address == sect->addr) {
|
|
424 X *address = region.address;
|
|
425 X *size = region.size;
|
|
426 X }
|
|
427 X }
|
|
428 X region.address += region.size;
|
|
429 X }
|
|
430 X return (1);
|
|
431 }
|
|
432 X
|
|
433 static char *
|
|
434 my_malloc(
|
|
435 X vm_size_t size
|
|
436 X )
|
|
437 {
|
|
438 X vm_address_t address;
|
|
439 X
|
|
440 X if (vm_allocate(task_self(), &address, size, TRUE) != KERN_SUCCESS) {
|
|
441 X return (NULL);
|
|
442 X }
|
|
443 X return ((char *)address);
|
|
444 }
|
|
445 X
|
|
446 static void
|
|
447 my_free(
|
|
448 X char *buf,
|
|
449 X vm_size_t size
|
|
450 X )
|
|
451 {
|
|
452 X vm_deallocate(task_self(), (vm_address_t)buf, size);
|
|
453 }
|
|
454 X
|
|
455 static int
|
|
456 unexec_doit(
|
|
457 X int infd,
|
|
458 X int outfd
|
|
459 X )
|
|
460 {
|
|
461 X int i;
|
|
462 X struct load_command **the_commands = NULL;
|
|
463 X unsigned the_commands_len;
|
|
464 X struct mach_header the_header;
|
|
465 X int fgrowth;
|
|
466 X int fdatastart;
|
|
467 X int fdatasize;
|
|
468 X int size;
|
|
469 X struct stat st;
|
|
470 X char *buf;
|
|
471 X vm_address_t data_address;
|
|
472 X vm_size_t data_size;
|
|
473 X
|
|
474 X struct segment_command *segment;
|
|
475 X
|
|
476 X if (!read_macho(infd, &the_header, &the_commands, &the_commands_len)) {
|
|
477 X return (0);
|
|
478 X }
|
|
479 X
|
|
480 X
|
|
481 X {
|
|
482 X extern int malloc_cookie;
|
|
483 X malloc_cookie = malloc_freezedry();
|
|
484 X }
|
|
485 X if (!get_data_region(&data_address, &data_size)) {
|
|
486 X return (0);
|
|
487 X }
|
|
488 X
|
|
489 X
|
|
490 X /*
|
|
491 X * DO NOT USE MALLOC IN THIS SECTION
|
|
492 X */
|
|
493 X {
|
|
494 X /*
|
|
495 X * Fix offsets
|
|
496 X */
|
|
497 X for (i = 0; i < the_commands_len; i++) {
|
|
498 X switch (the_commands[i]->cmd) {
|
|
499 X case LC_SEGMENT:
|
|
500 X segment = ((struct segment_command *)
|
|
501 X the_commands[i]);
|
|
502 X if (strcmp(segment->segname, SEG_DATA) == 0) {
|
|
503 X fdatastart = segment->fileoff;
|
|
504 X fdatasize = segment->filesize;
|
|
505 X fgrowth = (data_size -
|
|
506 X segment->filesize);
|
|
507 X segment->vmsize = data_size;
|
|
508 X segment->filesize = data_size;
|
|
509 X }
|
|
510 X break;
|
|
511 X case LC_SYMTAB:
|
|
512 X ((struct symtab_command *)
|
|
513 X the_commands[i])->symoff += fgrowth;
|
|
514 X ((struct symtab_command *)
|
|
515 X the_commands[i])->stroff += fgrowth;
|
|
516 X break;
|
|
517 X case LC_SYMSEG:
|
|
518 X ((struct symseg_command *)
|
|
519 X the_commands[i])->offset += fgrowth;
|
|
520 X break;
|
|
521 X default:
|
|
522 X break;
|
|
523 X }
|
|
524 X }
|
|
525 X
|
|
526 X /*
|
|
527 X * Write header
|
|
528 X */
|
|
529 X if (write(outfd, &the_header,
|
|
530 X sizeof(the_header)) != sizeof(the_header)) {
|
|
531 X fatal_unexec("cannot write output file");
|
|
532 X return (0);
|
|
533 X }
|
|
534 X
|
|
535 X /*
|
|
536 X * Write commands
|
|
537 X */
|
|
538 X for (i = 0; i < the_commands_len; i++) {
|
|
539 X if (write(outfd, the_commands[i],
|
|
540 X the_commands[i]->cmdsize) !=
|
|
541 X the_commands[i]->cmdsize) {
|
|
542 X fatal_unexec("cannot write output file");
|
|
543 X return (0);
|
|
544 X }
|
|
545 X }
|
|
546 X
|
|
547 X /*
|
|
548 X * Write original text
|
|
549 X */
|
|
550 X if (lseek(infd, the_header.sizeofcmds + sizeof(the_header),
|
|
551 X L_SET) < 0) {
|
|
552 X fatal_unexec("cannot seek input file");
|
|
553 X return (0);
|
|
554 X }
|
|
555 X size = fdatastart - (sizeof(the_header) +
|
|
556 X the_header.sizeofcmds);
|
|
557 X buf = my_malloc(size);
|
|
558 X if (read(infd, buf, size) != size) {
|
|
559 X my_free(buf, size);
|
|
560 X fatal_unexec("cannot read input file");
|
|
561 X }
|
|
562 X if (write(outfd, buf, size) != size) {
|
|
563 X my_free(buf, size);
|
|
564 X fatal_unexec("cannot write output file");
|
|
565 X return (0);
|
|
566 X }
|
|
567 X my_free(buf, size);
|
|
568 X
|
|
569 X
|
|
570 X /*
|
|
571 X * Write new data
|
|
572 X */
|
|
573 X if (write(outfd, (char *)data_address,
|
|
574 X data_size) != data_size) {
|
|
575 X fatal_unexec("cannot write output file");
|
|
576 X return (0);
|
|
577 X }
|
|
578 X
|
|
579 X }
|
|
580 X
|
|
581 X /*
|
|
582 X * OKAY TO USE MALLOC NOW
|
|
583 X */
|
|
584 X
|
|
585 X /*
|
|
586 X * Write rest of file
|
|
587 X */
|
|
588 X fstat(infd, &st);
|
|
589 X if (lseek(infd, fdatasize, L_INCR) < 0) {
|
|
590 X fatal_unexec("cannot seek input file");
|
|
591 X return (0);
|
|
592 X }
|
|
593 X size = st.st_size - lseek(infd, 0, L_INCR);
|
|
594 X
|
|
595 X buf = malloc(size);
|
|
596 X if (read(infd, buf, size) != size) {
|
|
597 X free(buf);
|
|
598 X fatal_unexec("cannot read input file");
|
|
599 X return (0);
|
|
600 X }
|
|
601 X if (write(outfd, buf, size) != size) {
|
|
602 X free(buf);
|
|
603 X fatal_unexec("cannot write output file");
|
|
604 X return (0);
|
|
605 X }
|
|
606 X free(buf);
|
|
607 X return (1);
|
|
608 }
|
|
609 X
|
|
610 void
|
|
611 unexec(
|
|
612 X char *outfile,
|
|
613 X char *infile
|
|
614 X )
|
|
615 {
|
|
616 X int infd;
|
|
617 X int outfd;
|
|
618 X char tmpbuf[L_tmpnam];
|
|
619 X char *tmpfile;
|
|
620 X
|
|
621 X infd = open(infile, O_RDONLY, 0);
|
|
622 X if (infd < 0) {
|
|
623 X fatal_unexec("cannot open input file `%s'", infile);
|
|
624 X exit(1);
|
|
625 X }
|
|
626 X
|
|
627 X tmpnam(tmpbuf);
|
|
628 X tmpfile = rindex(tmpbuf, '/');
|
|
629 X if (tmpfile == NULL) {
|
|
630 X tmpfile = tmpbuf;
|
|
631 X } else {
|
|
632 X tmpfile++;
|
|
633 X }
|
|
634 X outfd = open(tmpfile, O_WRONLY|O_TRUNC|O_CREAT, 0755);
|
|
635 X if (outfd < 0) {
|
|
636 X close(infd);
|
|
637 X fatal_unexec("cannot open tmp file `%s'", tmpfile);
|
|
638 X exit(1);
|
|
639 X }
|
|
640 X if (!unexec_doit(infd, outfd)) {
|
|
641 X close(infd);
|
|
642 X close(outfd);
|
|
643 X unlink(tmpfile);
|
|
644 X exit(1);
|
|
645 X }
|
|
646 X close(infd);
|
|
647 X close(outfd);
|
|
648 X if (rename(tmpfile, outfile) < 0) {
|
|
649 X unlink(tmpfile);
|
|
650 X fatal_unexec("cannot rename `%s' to `%s'", tmpfile, outfile);
|
|
651 X exit(1);
|
|
652 X }
|
|
653 }
|
|
654 #endif
|
|
655 X
|
|
656 SHAR_EOF
|
|
657 chmod 0644 unexNeXT.c ||
|
|
658 echo 'restore of unexNeXT.c failed'
|
|
659 Wc_c="`wc -c < 'unexNeXT.c'`"
|
|
660 test 8482 -eq "$Wc_c" ||
|
|
661 echo 'unexNeXT.c: original size 8482, current size' "$Wc_c"
|
|
662 fi
|
|
663 # ============= patch-for-NeXT ==============
|
|
664 if test -f 'patch-for-NeXT' -a X"$1" != X"-c"; then
|
|
665 echo 'x - skipping patch-for-NeXT (File already exists)'
|
|
666 else
|
|
667 echo 'x - extracting patch-for-NeXT (Text)'
|
|
668 sed 's/^X//' << 'SHAR_EOF' > 'patch-for-NeXT' &&
|
|
669 diff -rc tmp/mule-0.9.4/src/emacs.c mule-0.9.4/src/emacs.c
|
|
670 *** tmp/mule-0.9.4/src/emacs.c Thu May 28 16:34:57 1992
|
|
671 --- mule-0.9.4/src/emacs.c Tue Jun 9 09:05:54 1992
|
|
672 ***************
|
|
673 *** 229,234 ****
|
|
674 --- 229,240 ----
|
|
675 X #endif /* LINK_CRTL_SHARE */
|
|
676 X #endif /* VMS */
|
|
677 X
|
|
678 + #ifdef NeXT
|
|
679 + #include <mach.h>
|
|
680 + int malloc_cookie;
|
|
681 + NXZone *emacszone;
|
|
682 + #endif
|
|
683 +
|
|
684 X /* ARGSUSED */
|
|
685 X main (argc, argv, envp)
|
|
686 X int argc;
|
|
687 ***************
|
|
688 *** 238,243 ****
|
|
689 --- 244,260 ----
|
|
690 X int skip_args = 0;
|
|
691 X extern int errno;
|
|
692 X extern void malloc_warning ();
|
|
693 +
|
|
694 + #ifdef NeXT
|
|
695 + if (initialized) {
|
|
696 + if (malloc_jumpstart(malloc_cookie) != 0)
|
|
697 + fatal("malloc jumpstart failed!\n");
|
|
698 + } else {
|
|
699 + emacszone = NXCreateZone(ZONESIZE*vm_page_size,vm_page_size,1);
|
|
700 + if(emacszone == NX_NOZONE)
|
|
701 + fatal("can't create emacs zone.\n");
|
|
702 + }
|
|
703 + #endif
|
|
704 X
|
|
705 X /* Map in shared memory, if we are using that. */
|
|
706 X #ifdef HAVE_SHM
|
|
707 diff -rc tmp/mule-0.9.4/src/fileio.c mule-0.9.4/src/fileio.c
|
|
708 *** tmp/mule-0.9.4/src/fileio.c Thu May 28 16:34:58 1992
|
|
709 --- mule-0.9.4/src/fileio.c Mon Jun 8 18:48:52 1992
|
|
710 ***************
|
|
711 *** 1586,1592 ****
|
|
712 --- 1586,1594 ----
|
|
713 X close (XFASTINT (fd));
|
|
714 X }
|
|
715 X
|
|
716 + #ifndef READ_BUF_SIZE
|
|
717 X #define READ_BUF_SIZE 1048576 /* 92.5.28 by K.Handa */
|
|
718 + #endif
|
|
719 X
|
|
720 X DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
|
|
721 X 1, 3, 0,
|
|
722 diff -rc tmp/mule-0.9.4/src/fns.c mule-0.9.4/src/fns.c
|
|
723 *** tmp/mule-0.9.4/src/fns.c Thu May 28 16:29:46 1992
|
|
724 --- mule-0.9.4/src/fns.c Tue Jun 9 09:03:05 1992
|
|
725 ***************
|
|
726 *** 1118,1123 ****
|
|
727 --- 1118,1126 ----
|
|
728 X }
|
|
729 X }
|
|
730 X
|
|
731 + #ifdef LOAD_AVE_MACH
|
|
732 + #include <mach.h>
|
|
733 + #else
|
|
734 X /* Avoid static vars inside a function since in HPUX they dump as pure. */
|
|
735 X #ifdef DGUX
|
|
736 X static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
|
|
737 ***************
|
|
738 *** 1136,1141 ****
|
|
739 --- 1139,1145 ----
|
|
740 X #define initialized ldav_initialized
|
|
741 X #define nl ldav_nl
|
|
742 X #endif /* Not DGUX */
|
|
743 + #endif /* not LOAD_AVE_MACH */
|
|
744 X
|
|
745 X DEFUN ("load-average", Fload_average, Sload_average, 0, 0, 0,
|
|
746 X "Return the current 1 minute, 5 minute and 15 minute load averages\n\
|
|
747 ***************
|
|
748 *** 1143,1148 ****
|
|
749 --- 1147,1177 ----
|
|
750 X and then turned into integers).")
|
|
751 X ()
|
|
752 X {
|
|
753 + #ifdef LOAD_AVE_MACH
|
|
754 + kern_return_t error;
|
|
755 + host_t host;
|
|
756 + unsigned int info_count;
|
|
757 + struct processor_set_basic_info info;
|
|
758 + processor_set_t default_set;
|
|
759 +
|
|
760 + int load_ave = 0;
|
|
761 + /* int mach_fac = 0; mach factor(not used)*/
|
|
762 +
|
|
763 + error=processor_set_default(host_self(), &default_set);
|
|
764 + if (error==KERN_SUCCESS){
|
|
765 + info_count=PROCESSOR_SET_BASIC_INFO_COUNT;
|
|
766 + error=processor_set_info(default_set, PROCESSOR_SET_BASIC_INFO,
|
|
767 + &host, (processor_set_info_t)&info, &info_count);
|
|
768 + if (error == KERN_SUCCESS) {
|
|
769 + load_ave = (int)((float)info.load_average * 100.0 / LOAD_SCALE);
|
|
770 + /* mach_fac = (int)((float)info.mach_factor * 100.0 / LOAD_SCALE); */
|
|
771 + }
|
|
772 + }
|
|
773 +
|
|
774 + return Fcons (make_number (load_ave),
|
|
775 + Fcons (make_number (load_ave),
|
|
776 + Fcons (make_number (load_ave), Qnil)));
|
|
777 + #else /* not LOAD_AVE_MACH */
|
|
778 X #ifdef DGUX
|
|
779 X /* perhaps there should be a "sys_load_avg" call in sysdep.c?! - DJB */
|
|
780 X load_info.one_minute = 0.0; /* just in case there is an error */
|
|
781 ***************
|
|
782 *** 1225,1237 ****
|
|
783 X strcpy (nl[0].n_name, LDAV_SYMBOL);
|
|
784 X nl[1].n_zeroes = 0;
|
|
785 X #else /* NLIST_STRUCT */
|
|
786 ! #ifdef convex
|
|
787 X nl[0].n_un.n_name = LDAV_SYMBOL;
|
|
788 X nl[1].n_un.n_name = 0;
|
|
789 ! #else /* not convex */
|
|
790 X nl[0].n_name = LDAV_SYMBOL;
|
|
791 X nl[1].n_name = 0;
|
|
792 ! #endif /* not convex */
|
|
793 X #endif /* NLIST_STRUCT */
|
|
794 X
|
|
795 X #ifdef IRIS_4D
|
|
796 --- 1254,1266 ----
|
|
797 X strcpy (nl[0].n_name, LDAV_SYMBOL);
|
|
798 X nl[1].n_zeroes = 0;
|
|
799 X #else /* NLIST_STRUCT */
|
|
800 ! #if defined(convex) || defined(NeXT)
|
|
801 X nl[0].n_un.n_name = LDAV_SYMBOL;
|
|
802 X nl[1].n_un.n_name = 0;
|
|
803 ! #else /* not convex, not NeXT */
|
|
804 X nl[0].n_name = LDAV_SYMBOL;
|
|
805 X nl[1].n_name = 0;
|
|
806 ! #endif /* not convex, not NeXT */
|
|
807 X #endif /* NLIST_STRUCT */
|
|
808 X
|
|
809 X #ifdef IRIS_4D
|
|
810 ***************
|
|
811 *** 1242,1248 ****
|
|
812 --- 1271,1281 ----
|
|
813 X nl[0].n_value &= 0x7fffffff;
|
|
814 X }
|
|
815 X #else
|
|
816 + #ifdef KERN_FILE
|
|
817 + nlist (KERN_FILE, nl);
|
|
818 + #else
|
|
819 X nlist (KERNEL_FILE, nl);
|
|
820 + #endif
|
|
821 X #endif /* IRIS */
|
|
822 X
|
|
823 X #ifdef FIXUP_KERNEL_SYMBOL_ADDR
|
|
824 ***************
|
|
825 *** 1288,1293 ****
|
|
826 --- 1321,1327 ----
|
|
827 X Qnil)));
|
|
828 X #endif /* LOAD_AVE_TYPE */
|
|
829 X #endif /* not DGUX */
|
|
830 + #endif /* not LOAD_AVE_MACH */
|
|
831 X }
|
|
832 X
|
|
833 X #undef channel
|
|
834 diff -rc tmp/mule-0.9.4/src/lisp.h mule-0.9.4/src/lisp.h
|
|
835 *** tmp/mule-0.9.4/src/lisp.h Thu May 28 16:29:53 1992
|
|
836 --- mule-0.9.4/src/lisp.h Tue Jun 9 09:08:30 1992
|
|
837 ***************
|
|
838 *** 1007,1013 ****
|
|
839 X
|
|
840 X extern void debugger ();
|
|
841 X
|
|
842 ! extern char *malloc (), *realloc (), *getenv (), *ctime (), *getwd ();
|
|
843 X extern long *xmalloc (), *xrealloc ();
|
|
844 X
|
|
845 X #ifdef MAINTAIN_ENVIRONMENT
|
|
846 --- 1007,1016 ----
|
|
847 X
|
|
848 X extern void debugger ();
|
|
849 X
|
|
850 ! #ifndef malloc
|
|
851 ! extern char *malloc (), *realloc ();
|
|
852 ! #endif
|
|
853 ! extern char *getenv (), *ctime (), *getwd ();
|
|
854 X extern long *xmalloc (), *xrealloc ();
|
|
855 X
|
|
856 X #ifdef MAINTAIN_ENVIRONMENT
|
|
857 SHAR_EOF
|
|
858 chmod 0644 patch-for-NeXT ||
|
|
859 echo 'restore of patch-for-NeXT failed'
|
|
860 Wc_c="`wc -c < 'patch-for-NeXT'`"
|
|
861 test 5202 -eq "$Wc_c" ||
|
|
862 echo 'patch-for-NeXT: original size 5202, current size' "$Wc_c"
|
|
863 fi
|
|
864 exit 0
|
|
865
|
|
866 --
|
|
867 $B%-%d%N%s3t<02q<R(B
|
|
868 $B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?!<(B
|
|
869 $B=)MU4nG7(B akiba@cbs.canon.co.jp
|
|
870
|
|
871 ============================================================
|
|
872 Date: Mon, 15 Jun 92 10:20:23 JST
|
|
873 From: akiba@cbs.canon.co.jp (Yoshiyuki Akiba)
|
|
874 Return-Path: <akiba@cbs.canon.co.jp>
|
|
875 To: mule@etl.go.jp
|
|
876 In-Reply-To: Yoshiyuki Akiba's message of Fri, 12 Jun 92 10:22:51 JST <9206120122.AA19043@scarab.cbs.canon.co.jp>
|
|
877 Subject: Re: Patch for NeXT
|
|
878
|
|
879
|
|
880 *jserver$B$b(BNeXT$B>e$GF0$+$7$?$$J}$K(B*
|
|
881
|
|
882 jserver$B$b(BNeXT$B>e$GF0$+$9$3$H$,$G$-$^$9$,!"(Bkill$B$9$k$H$-$K(B
|
|
883 PANIC $B$r5/$3$7$^$9!#860x$O!";HMQ$7$F$$$J$$%=%1%C%H$r(B
|
|
884 shutdown()$B$7$F$$$k$?$a$G$9!#<!$N%Q%C%A$G2sHr$G$-$^$9!#(B
|
|
885
|
|
886 (Wnn 4.03$B$N;~$N%Q%C%A$J$N$G!"$=$N$^$^$G$O$"$?$i$J$$$+$b(B
|
|
887 $BCN$l$^$;$s$,NL$,>/$J$$$N$G$3$l$G4*J[$7$F2<$5$$!#(B:-)
|
|
888
|
|
889 diff -rcN Wnn/jserver/de.c wnn/jserver/de.c
|
|
890 *** Wnn/jserver/de.c Fri Aug 30 15:52:39 1991
|
|
891 --- wnn/jserver/de.c Fri Aug 30 17:26:14 1991
|
|
892 ***************
|
|
893 *** 459,465 ****
|
|
894 shutdown(sock_d_in, 2);
|
|
895 close(sock_d_in);
|
|
896
|
|
897 ! for (fd = nofile; fd >= 0; fd--) {
|
|
898 shutdown(fd, 2);
|
|
899 close(fd);
|
|
900 }
|
|
901 --- 470,477 ----
|
|
902 shutdown(sock_d_in, 2);
|
|
903 close(sock_d_in);
|
|
904
|
|
905 ! for (fd = nofile-1; fd >= 0; fd--) {
|
|
906 ! if( (fd!=sock_d_in)&&(fd!=sock_d_un)&&sock_tst(all_socks, fd) )
|
|
907 shutdown(fd, 2);
|
|
908 close(fd);
|
|
909 }
|
|
910 --
|
|
911 $B%-%d%N%s3t<02q<R(B
|
|
912 $B%3%s%T%e!<%?1~MQ%7%9%F%`5;=Q3+H/%;%s%?!<(B
|
|
913 $B=)MU4nG7(B akiba@cbs.canon.co.jp
|
|
914
|