summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/collect2.c30
-rw-r--r--gcc/gcc.c21
-rw-r--r--gcc/protoize.c21
3 files changed, 57 insertions, 15 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 8b98be6168f..d810aca6e06 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);
+ }
}
}
}
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 2f9362112b7..e1e870e6423 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -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 00b7638ae29..f79871ee251 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;