Mercurial > hg > xemacs-beta
comparison src/unexhp9k800.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | a5df635868b2 |
children | 04bc9d2f42c7 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
56 #include <stdio.h> | 56 #include <stdio.h> |
57 #include <fcntl.h> | 57 #include <fcntl.h> |
58 #include <errno.h> | 58 #include <errno.h> |
59 | 59 |
60 #include <a.out.h> | 60 #include <a.out.h> |
61 #include "lisp.h" | |
61 | 62 |
62 /* | 63 /* |
63 * Minor modification to enable dumping with shared libraries added by | 64 * Minor modification to enable dumping with shared libraries added by |
64 * Dipankar Gupta (dg@hplb.hpl.hp.com). I studied Oliver Laumann's | 65 * Dipankar Gupta (dg@hplb.hpl.hp.com). I studied Oliver Laumann's |
65 * more elaborate dynamic loading scheme in ELK while implementing | 66 * more elaborate dynamic loading scheme in ELK while implementing |
79 * RUN_TIME_REMAP. | 80 * RUN_TIME_REMAP. |
80 */ | 81 */ |
81 | 82 |
82 #ifdef HPUX_USE_SHLIBS | 83 #ifdef HPUX_USE_SHLIBS |
83 #include <dl.h> /* User-space dynamic loader entry points */ | 84 #include <dl.h> /* User-space dynamic loader entry points */ |
84 void Save_Shared_Data(void); | 85 static void Save_Shared_Data (void); |
85 int run_time_remap(); | 86 static void Restore_Shared_Data (void); |
86 #endif | 87 #endif |
87 | |
88 #define min(x,y) ( ((x)<(y))?(x):(y) ) | |
89 | 88 |
90 void write_header(int file, struct header *hdr, struct som_exec_auxhdr *auxhdr); | 89 void write_header(int file, struct header *hdr, struct som_exec_auxhdr *auxhdr); |
91 void read_header (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr); | 90 void read_header (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr); |
92 void save_data_space (int file, struct header *hdr, | 91 void save_data_space (int file, struct header *hdr, |
93 struct som_exec_auxhdr *auxhdr, int size); | 92 struct som_exec_auxhdr *auxhdr, int size); |
98 unsigned int location, int offset); | 97 unsigned int location, int offset); |
99 int calculate_checksum(struct header *hdr); | 98 int calculate_checksum(struct header *hdr); |
100 | 99 |
101 /* Create a new a.out file, same as old but with current data space */ | 100 /* Create a new a.out file, same as old but with current data space */ |
102 int | 101 int |
103 unexec(char new_name[], /* name of the new a.out file to be created */ | 102 unexec (char *new_name, /* name of the new a.out file to be created */ |
104 char old_name[], /* name of the old a.out file */ | 103 char *old_name, /* name of the old a.out file */ |
105 char *new_end_of_text, /* ptr to new edata/etext; NOT USED YET */ | 104 uintptr_t new_end_of_text, /* ptr to new edata/etext; NOT USED YET */ |
106 int dummy1, int dummy2) /* not used by emacs */ | 105 uintptr_t dummy1, uintptr_t dummy2) /* not used by emacs */ |
107 { | 106 { |
108 int old, new; | 107 int old, new; |
109 int old_size, new_size; | 108 int old_size, new_size; |
110 struct header hdr; | 109 struct header hdr; |
111 struct som_exec_auxhdr auxhdr; | 110 struct som_exec_auxhdr auxhdr; |
289 int len; | 288 int len; |
290 int buffer[8192]; /* word aligned will be faster */ | 289 int buffer[8192]; /* word aligned will be faster */ |
291 | 290 |
292 for (; size > 0; size -= len) | 291 for (; size > 0; size -= len) |
293 { | 292 { |
294 len = min(size, sizeof(buffer)); | 293 len = size < sizeof (buffer) ? size : sizeof (buffer); |
295 if (read(old, buffer, len) != len) | 294 if (read (old, buffer, len) != len) |
296 { perror("Read failure on a.out file"); exit(1); } | 295 { |
297 if (write(new, buffer, len) != len) | 296 perror ("Read failure on a.out file"); |
298 { perror("Write failure in a.out file"); exit(1); } | 297 exit (1); |
298 } | |
299 if (write (new, buffer, len) != len) | |
300 { | |
301 perror ("Write failure in a.out file"); | |
302 exit (1); | |
303 } | |
299 } | 304 } |
300 } | 305 } |
301 | 306 |
302 /* Copy the rest of the file, up to EOF. */ | 307 /* Copy the rest of the file, up to EOF. */ |
303 void | 308 void |
336 #ifdef HPUX_USE_SHLIBS | 341 #ifdef HPUX_USE_SHLIBS |
337 /* Added machinery for shared libs... see comments at the beginning of this file. */ | 342 /* Added machinery for shared libs... see comments at the beginning of this file. */ |
338 | 343 |
339 void *Brk_On_Dump = 0; /* Brk value to restore... stored as a global */ | 344 void *Brk_On_Dump = 0; /* Brk value to restore... stored as a global */ |
340 | 345 |
341 void Save_Shared_Data () { | 346 static void |
342 Brk_On_Dump = sbrk( 0 ); | 347 Save_Shared_Data (void) |
343 } | 348 { |
344 | 349 Brk_On_Dump = sbrk (0); |
345 void Restore_Shared_Data () { | 350 } |
346 brk ( Brk_On_Dump ); | 351 |
347 } | 352 static void |
348 | 353 Restore_Shared_Data (void) |
349 int run_time_remap (int d) { | 354 { |
350 Restore_Shared_Data(); | 355 brk (Brk_On_Dump); |
351 } | 356 } |
352 | 357 |
353 /* run_time_remap is the magic called by startup code in the dumped executable | 358 /* run_time_remap is the magic called by startup code in the dumped executable |
354 * if RUN_TIME_REMAP is set. | 359 if RUN_TIME_REMAP is set. */ |
355 */ | 360 int |
361 run_time_remap (char *dummy) | |
362 { | |
363 Restore_Shared_Data (); | |
364 return 0; | |
365 } | |
356 #endif /* HPUX_USE_SHLIBS */ | 366 #endif /* HPUX_USE_SHLIBS */ |