|
12 | 12 | #include <stdlib.h> |
13 | 13 | #include <unistd.h> |
14 | 14 | #include <string.h> |
| 15 | +#include <mint/osbind.h> |
15 | 16 | #include "lib.h" |
16 | 17 |
|
| 18 | +#ifdef __OPTIMIZE__ |
| 19 | +#pragma GCC optimize "-Os" |
| 20 | +#endif |
| 21 | + |
17 | 22 | /* Abort with an error message. |
18 | 23 | This function should write MESSAGE out in the most reliable way. |
19 | 24 | It is called in situations like internal stdio lossage. */ |
20 | 25 |
|
21 | 26 | void |
22 | | -__libc_fatal (register const char* message) |
| 27 | +__libc_fatal (const char* message) |
23 | 28 | { |
24 | 29 | size_t msglen = strlen (message); |
25 | | - register size_t i; |
26 | | - char* crlf = "\r\n"; |
27 | | - char* colon = ": fatal libc error: "; |
| 30 | + size_t i; |
| 31 | + static char const crlf[] = "\r\n"; |
| 32 | + static char const colon[] = ": fatal libc error: "; |
28 | 33 |
|
29 | | - __write (STDERR_FILENO, program_invocation_name, |
30 | | - strlen (program_invocation_name)); |
31 | | - __write (STDERR_FILENO, colon, sizeof colon - 1); |
| 34 | + Fwrite(STDERR_FILENO, strlen (program_invocation_name), program_invocation_name); |
| 35 | + Fwrite(STDERR_FILENO, sizeof(colon) - 1, colon); |
32 | 36 |
|
33 | 37 | /* We better write a CRLF sequence here. Of course this will make |
34 | 38 | the function slower but we want the user to be able to read |
35 | 39 | the message under all circumstances. */ |
36 | 40 | for (i = 0; i < msglen; i++) { |
37 | 41 | if (message[i] == '\n') |
38 | | - __write (STDERR_FILENO, crlf, 2); |
| 42 | + Fwrite(STDERR_FILENO, sizeof(crlf) - 1, crlf); |
39 | 43 | else |
40 | | - __write (STDERR_FILENO, (char*) message + i, 1); |
| 44 | + Fwrite(STDERR_FILENO, 1, message + i); |
41 | 45 | } |
42 | 46 |
|
43 | 47 | abort (); |
|
0 commit comments