--- ./src/unexelf.c Tue Oct 15 10:21:44 2002 +++ ../emacs-21.3/./src/unexelf.c Wed Jun 4 15:23:11 2003 @@ -422,11 +422,18 @@ */ #ifndef emacs -#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) +#define FATAL(a) fprintf (stderr, a), exit (1) +#define FATAL1(a, b) fprintf (stderr, a, b), exit (1) +#define FATAL2(a, b, c) fprintf (stderr, a, b, c), exit (1) +#define FATAL3(a, b, c, d) fprintf (stderr, a, b, c, d), exit (1) #include #else #include extern void fatal (char *, ...); +#define FATAL fatal +#define FATAL1 fatal +#define FATAL2 fatal +#define FATAL3 fatal #endif #include @@ -650,7 +657,7 @@ if (noerror) return -1; else - fatal ("Can't find %s in %s.\n", name, file_name); + FATAL2 ("Can't find %s in %s.\n", name, file_name); } return idx; @@ -709,15 +716,15 @@ old_file = open (old_name, O_RDONLY); if (old_file < 0) - fatal ("Can't open %s for reading: errno %d\n", old_name, errno); + FATAL2 ("Can't open %s for reading: errno %d\n", old_name, errno); if (fstat (old_file, &stat_buf) == -1) - fatal ("Can't fstat (%s): errno %d\n", old_name, errno); + FATAL2 ("Can't fstat (%s): errno %d\n", old_name, errno); #if MAP_ANON == 0 mmap_fd = open ("/dev/zero", O_RDONLY); if (mmap_fd < 0) - fatal ("Can't open /dev/zero for reading: errno %d\n", errno); + FATAL1 ("Can't open /dev/zero for reading: errno %d\n", errno); #endif /* We cannot use malloc here because that may use sbrk. If it does, @@ -728,10 +735,10 @@ old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, mmap_fd, 0); if (old_base == MAP_FAILED) - fatal ("Can't allocate buffer for %s\n", old_name); + FATAL1 ("Can't allocate buffer for %s\n", old_name); if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size) - fatal ("Didn't read all of %s: errno %d\n", old_name, errno); + FATAL2 ("Didn't read all of %s: errno %d\n", old_name, errno); /* Get pointers to headers & section names */ @@ -800,7 +807,7 @@ #endif if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size) - fatal (".bss shrank when undumping???\n", 0, 0); + FATAL (".bss shrank when undumping???\n"); /* Set the output file to the right size. Allocate a buffer to hold * the image of the new file. Set pointers to various interesting @@ -809,17 +816,17 @@ new_file = open (new_name, O_RDWR | O_CREAT, 0666); if (new_file < 0) - fatal ("Can't creat (%s): errno %d\n", new_name, errno); + FATAL2 ("Can't creat (%s): errno %d\n", new_name, errno); new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size; if (ftruncate (new_file, new_file_size)) - fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); + FATAL2 ("Can't ftruncate (%s): errno %d\n", new_name, errno); new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, mmap_fd, 0); if (new_base == MAP_FAILED) - fatal ("Can't allocate buffer for %s\n", old_name); + FATAL1 ("Can't allocate buffer for %s\n", old_name); new_file_h = (ElfW(Ehdr) *) new_base; new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff); @@ -877,7 +884,7 @@ > (old_sbss_index == -1 ? old_bss_addr : round_up (old_bss_addr, alignment))) - fatal ("Program segment above .bss in %s\n", old_name, 0); + FATAL1 ("Program segment above .bss in %s\n", old_name); if (NEW_PROGRAM_H (n).p_type == PT_LOAD && (round_up ((NEW_PROGRAM_H (n)).p_vaddr @@ -887,7 +894,7 @@ break; } if (n < 0) - fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0); + FATAL1 ("Couldn't find segment next to .bss in %s\n", old_name); /* Make sure that the size includes any padding before the old .bss section. */ @@ -918,7 +925,7 @@ ".data")) break; if (old_data_index == old_file_h->e_shnum) - fatal ("Can't find .data in %s.\n", old_name, 0); + FATAL1 ("Can't find .data in %s.\n", old_name); /* Walk through all section headers, insert the new data2 section right before the new bss section. */ @@ -1262,11 +1269,11 @@ * contents */ if (write (new_file, new_base, new_file_size) != new_file_size) - fatal ("Didn't write %d bytes to %s: errno %d\n", + FATAL3 ("Didn't write %d bytes to %s: errno %d\n", new_file_size, new_base, errno); if (close (new_file)) - fatal ("Can't close (%s): errno %d\n", new_name, errno); + FATAL2 ("Can't close (%s): errno %d\n", new_name, errno); munmap (new_base, new_file_size); @@ -1277,7 +1284,7 @@ #endif if (close (old_file)) - fatal ("Can't close (%s): errno %d\n", old_name, errno); + FATAL2 ("Can't close (%s): errno %d\n", old_name, errno); munmap (old_base, old_file_size); @@ -1284,11 +1291,11 @@ /* Make the new file executable */ if (stat (new_name, &stat_buf) == -1) - fatal ("Can't stat (%s): errno %d\n", new_name, errno); + FATAL2 ("Can't stat (%s): errno %d\n", new_name, errno); n = umask (777); umask (n); stat_buf.st_mode |= 0111 & ~n; if (chmod (new_name, stat_buf.st_mode) == -1) - fatal ("Can't chmod (%s): errno %d\n", new_name, errno); + FATAL2 ("Can't chmod (%s): errno %d\n", new_name, errno); }