OSDN Git Service

If the POSIX.1 wait macros are defined, use them.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Oct 1994 20:53:02 +0000 (20:53 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Oct 1994 20:53:02 +0000 (20:53 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@8213 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/collect2.c
gcc/gcc.c
gcc/protoize.c

index 8b98be6..d810aca 100644 (file)
@@ -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);
+           }
        }
     }
 }
index 2f93621..e1e870e 100644 (file)
--- 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;
          }
       }
index 00b7638..f79871e 100644 (file)
@@ -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;