diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 1994-10-04 20:53:02 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 1994-10-04 20:53:02 +0000 |
commit | 0b90f9c2dcde31078698a862dfcaaf5cc563ea94 (patch) | |
tree | 8a014280d417c4ddd255ddba5eab01de2180301a /gcc | |
parent | 713225d41db4603c3b42a96b7017190088f05623 (diff) | |
download | gcc-0b90f9c2dcde31078698a862dfcaaf5cc563ea94.zip gcc-0b90f9c2dcde31078698a862dfcaaf5cc563ea94.tar.gz gcc-0b90f9c2dcde31078698a862dfcaaf5cc563ea94.tar.bz2 |
If the POSIX.1 wait macros are defined, use them.
From-SVN: r8213
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/collect2.c | 30 | ||||
-rw-r--r-- | gcc/gcc.c | 21 | ||||
-rw-r--r-- | gcc/protoize.c | 21 |
3 files changed, 57 insertions, 15 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c index 8b98be6..d810aca 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -79,6 +79,19 @@ extern int sys_nerr; #define X_OK 1 #endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(S) ((S) & 0x7f) +#endif +#ifndef WIFEXITED +#define WIFEXITED(S) (((S) & 0xff) == 0) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) +#endif + /* On MSDOS, write temp files in current dir because there's no place else we can expect to use. */ #ifdef __MSDOS__ @@ -1254,11 +1267,9 @@ do_wait (prog) wait (&status); if (status) { - int sig = status & 0x7F; - int ret; - - if (sig != -1 && sig != 0) + if (WIFSIGNALED (status)) { + int sig = WTERMSIG (status); #ifdef NO_SYS_SIGLIST error ("%s terminated with signal %d %s", prog, @@ -1275,11 +1286,14 @@ do_wait (prog) my_exit (127); } - ret = ((status & 0xFF00) >> 8); - if (ret != -1 && ret != 0) + if (WIFEXITED (status)) { - error ("%s returned %d exit status", prog, ret); - my_exit (ret); + int ret = WEXITSTATUS (status); + if (ret != 0) + { + error ("%s returned %d exit status", prog, ret); + my_exit (ret); + } } } } @@ -60,6 +60,19 @@ compilation is specified by a string called a "spec". */ #define X_OK 1 #endif +#ifndef WIFSIGNALED +#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(S) ((S) & 0x7f) +#endif +#ifndef WIFEXITED +#define WIFEXITED(S) (((S) & 0xff) == 0) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) +#endif + /* Add prototype support. */ #ifndef PROTO #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) @@ -2262,13 +2275,15 @@ execute () if (commands[j].pid == pid) prog = commands[j].prog; - if ((status & 0x7F) != 0) + if (WIFSIGNALED (status)) { fatal ("Internal compiler error: program %s got fatal signal %d", - prog, (status & 0x7F)); + prog, WTERMSIG (status)); signal_count++; + ret_code = -1; } - if (((status & 0xFF00) >> 8) >= MIN_FATAL_STATUS) + else if (WIFEXITED (status) + && WEXITSTATUS (status) >= MIN_FATAL_STATUS) ret_code = -1; } } diff --git a/gcc/protoize.c b/gcc/protoize.c index 00b7638..f79871e 100644 --- a/gcc/protoize.c +++ b/gcc/protoize.c @@ -132,6 +132,19 @@ typedef char * const_pointer_type; #define O_RDONLY 0 #define O_WRONLY 1 +#ifndef WIFSIGNALED +#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) +#endif +#ifndef WTERMSIG +#define WTERMSIG(S) ((S) & 0x7f) +#endif +#ifndef WIFEXITED +#define WIFEXITED(S) (((S) & 0xff) == 0) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) +#endif + /* Declaring stat or __flsbuf with a prototype causes conflicts with system headers on some systems. */ @@ -2090,16 +2103,16 @@ gen_aux_info_file (base_filename) pname, sys_errlist[errno]); return 0; } - if ((wait_status & 0x7F) != 0) + if (WIFSIGNALED (wait_status)) { fprintf (stderr, "%s: subprocess got fatal signal %d", - pname, (wait_status & 0x7F)); + pname, WTERMSIG (wait_status)); return 0; } - if (((wait_status & 0xFF00) >> 8) != 0) + if (WIFEXITED (wait_status) && WEXITSTATUS (wait_status) != 0) { fprintf (stderr, "%s: %s exited with status %d\n", - pname, base_filename, ((wait_status & 0xFF00) >> 8)); + pname, base_filename, WEXITSTATUS (wait_status)); return 0; } return 1; |