diff options
| author | Paul Eggert | 2013-02-11 12:32:54 -0800 |
|---|---|---|
| committer | Paul Eggert | 2013-02-11 12:32:54 -0800 |
| commit | 227be86d105d077b281e6a123ba2cc166635a429 (patch) | |
| tree | ab0c085c69dcbe041b376b3b28bcbea1dcd24dea /src | |
| parent | 713bfeaab314f4ae943a19205d7db71cb3e70745 (diff) | |
| download | emacs-227be86d105d077b281e6a123ba2cc166635a429.tar.gz emacs-227be86d105d077b281e6a123ba2cc166635a429.zip | |
Improve AIX port.
This doesn't fix the bug, but it makes progress: Emacs builds now.
* unexaix.c: Include inttypes.h, stdarg.h.
(report_error, report_error_1): Mark as _Noreturn.
(report_error): Don't report the wrong errno.
(report_error_1): Now varargs. All callers changed.
(make_hdr): Use uintptr_t, not unsigned, when converting pointers
to unsigned. Don't use ADDR_CORRECT, as it no longer exists.
(write_ptr): Use %p to print address rather than %lx and a cast
to unsigned long. Grow buffer a bit, to be safer.
Fixes: debbugs:13650
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/unexaix.c | 46 |
2 files changed, 42 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b5a1e0d5cb5..8397e3d26ec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2013-02-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Improve AIX port (Bug#13650). | ||
| 4 | This doesn't fix the bug, but it makes progress: Emacs builds now. | ||
| 5 | * unexaix.c: Include inttypes.h, stdarg.h. | ||
| 6 | (report_error, report_error_1): Mark as _Noreturn. | ||
| 7 | (report_error): Don't report the wrong errno. | ||
| 8 | (report_error_1): Now varargs. All callers changed. | ||
| 9 | (make_hdr): Use uintptr_t, not unsigned, when converting pointers | ||
| 10 | to unsigned. Don't use ADDR_CORRECT, as it no longer exists. | ||
| 11 | (write_ptr): Use %p to print address rather than %lx and a cast | ||
| 12 | to unsigned long. Grow buffer a bit, to be safer. | ||
| 13 | |||
| 1 | 2013-02-11 Eli Zaretskii <eliz@gnu.org> | 14 | 2013-02-11 Eli Zaretskii <eliz@gnu.org> |
| 2 | 15 | ||
| 3 | * bidi.c (bidi_resolve_neutral): After finding the next | 16 | * bidi.c (bidi_resolve_neutral): After finding the next |
diff --git a/src/unexaix.c b/src/unexaix.c index 92ebd2e3ceb..a3ffd509058 100644 --- a/src/unexaix.c +++ b/src/unexaix.c | |||
| @@ -51,6 +51,8 @@ what you give them. Help stamp out software-hoarding! */ | |||
| 51 | #include "getpagesize.h" | 51 | #include "getpagesize.h" |
| 52 | 52 | ||
| 53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
| 54 | #include <inttypes.h> | ||
| 55 | #include <stdarg.h> | ||
| 54 | #include <stdio.h> | 56 | #include <stdio.h> |
| 55 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
| 56 | #include <errno.h> | 58 | #include <errno.h> |
| @@ -92,23 +94,30 @@ static int pagemask; | |||
| 92 | 94 | ||
| 93 | #include "lisp.h" | 95 | #include "lisp.h" |
| 94 | 96 | ||
| 95 | static void | 97 | static _Noreturn void |
| 96 | report_error (const char *file, int fd) | 98 | report_error (const char *file, int fd) |
| 97 | { | 99 | { |
| 98 | if (fd) | 100 | if (fd) |
| 99 | close (fd); | 101 | { |
| 102 | int failed_errno = errno; | ||
| 103 | close (fd); | ||
| 104 | errno = failed_errno; | ||
| 105 | } | ||
| 100 | report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); | 106 | report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); |
| 101 | } | 107 | } |
| 102 | 108 | ||
| 103 | #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 | 109 | #define ERROR0(msg) report_error_1 (new, msg) |
| 104 | #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 | 110 | #define ERROR1(msg,x) report_error_1 (new, msg, x) |
| 105 | #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 | 111 | #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y) |
| 106 | 112 | ||
| 107 | static void | 113 | static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3) |
| 108 | report_error_1 (int fd, const char *msg, int a1, int a2) | 114 | report_error_1 (int fd, const char *msg, ...) |
| 109 | { | 115 | { |
| 116 | va_list ap; | ||
| 110 | close (fd); | 117 | close (fd); |
| 111 | error (msg, a1, a2); | 118 | va_start (ap, msg); |
| 119 | verror (msg, ap); | ||
| 120 | va_end (ap); | ||
| 112 | } | 121 | } |
| 113 | 122 | ||
| 114 | static int make_hdr (int, int, const char *, const char *); | 123 | static int make_hdr (int, int, const char *, const char *); |
| @@ -163,8 +172,8 @@ make_hdr (int new, int a_out, | |||
| 163 | const char *a_name, const char *new_name) | 172 | const char *a_name, const char *new_name) |
| 164 | { | 173 | { |
| 165 | int scns; | 174 | int scns; |
| 166 | unsigned int bss_start; | 175 | uintptr_t bss_start; |
| 167 | unsigned int data_start; | 176 | uintptr_t data_start; |
| 168 | 177 | ||
| 169 | struct scnhdr section[MAX_SECTIONS]; | 178 | struct scnhdr section[MAX_SECTIONS]; |
| 170 | struct scnhdr * f_thdr; /* Text section header */ | 179 | struct scnhdr * f_thdr; /* Text section header */ |
| @@ -179,17 +188,17 @@ make_hdr (int new, int a_out, | |||
| 179 | pagemask = getpagesize () - 1; | 188 | pagemask = getpagesize () - 1; |
| 180 | 189 | ||
| 181 | /* Adjust text/data boundary. */ | 190 | /* Adjust text/data boundary. */ |
| 182 | data_start = (long) start_of_data (); | 191 | data_start = (uintptr_t) start_of_data (); |
| 183 | data_start = ADDR_CORRECT (data_start); | ||
| 184 | 192 | ||
| 185 | data_start = data_start & ~pagemask; /* (Down) to page boundary. */ | 193 | data_start = data_start & ~pagemask; /* (Down) to page boundary. */ |
| 186 | 194 | ||
| 187 | bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; | 195 | bss_start = (uintptr_t) sbrk (0) + pagemask; |
| 188 | bss_start &= ~ pagemask; | 196 | bss_start &= ~ pagemask; |
| 189 | 197 | ||
| 190 | if (data_start > bss_start) /* Can't have negative data size. */ | 198 | if (data_start > bss_start) /* Can't have negative data size. */ |
| 191 | { | 199 | { |
| 192 | ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)", | 200 | ERROR2 (("unexec: data_start (0x%"PRIxPTR |
| 201 | ") can't be greater than bss_start (0x%"PRIxPTR")"), | ||
| 193 | data_start, bss_start); | 202 | data_start, bss_start); |
| 194 | } | 203 | } |
| 195 | 204 | ||
| @@ -393,7 +402,6 @@ static void | |||
| 393 | write_segment (int new, char *ptr, char *end) | 402 | write_segment (int new, char *ptr, char *end) |
| 394 | { | 403 | { |
| 395 | int i, nwrite, ret; | 404 | int i, nwrite, ret; |
| 396 | char buf[80]; | ||
| 397 | char zeros[UnexBlockSz]; | 405 | char zeros[UnexBlockSz]; |
| 398 | 406 | ||
| 399 | for (i = 0; ptr < end;) | 407 | for (i = 0; ptr < end;) |
| @@ -414,9 +422,13 @@ write_segment (int new, char *ptr, char *end) | |||
| 414 | } | 422 | } |
| 415 | else if (nwrite != ret) | 423 | else if (nwrite != ret) |
| 416 | { | 424 | { |
| 425 | int write_errno = errno; | ||
| 426 | char buf[1000]; | ||
| 427 | void *addr = ptr; | ||
| 417 | sprintf (buf, | 428 | sprintf (buf, |
| 418 | "unexec write failure: addr 0x%lx, fileno %d, size 0x%x, wrote 0x%x, errno %d", | 429 | "unexec write failure: addr %p, fileno %d, size 0x%x, wrote 0x%x, errno %d", |
| 419 | (unsigned long)ptr, new, nwrite, ret, errno); | 430 | addr, new, nwrite, ret, errno); |
| 431 | errno = write_errno; | ||
| 420 | PERROR (buf); | 432 | PERROR (buf); |
| 421 | } | 433 | } |
| 422 | i += nwrite; | 434 | i += nwrite; |