changeset 18906:4586051a5ff1

WIFEXITED and WEXITSTATUS macros for mkoctfile.cc * mkoctfile.in.cc (WIFEXITED, WEXITSTATUS): Define for systems that don't have these macros.
author John W. Eaton <jwe@octave.org>
date Fri, 27 Jun 2014 17:09:28 -0400
parents 2b82d2f29a7b
children 85d04dfdeac3
files src/mkoctfile.in.cc
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/mkoctfile.in.cc	Fri Jun 27 11:56:19 2014 -0400
+++ b/src/mkoctfile.in.cc	Fri Jun 27 17:09:28 2014 -0400
@@ -37,6 +37,22 @@
 
 #include <unistd.h>
 
+// This mess suggested by the autoconf manual.
+
+#include <sys/types.h>
+
+#if defined HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) (static_cast<unsigned> (stat_val) >> 8)
+#endif
+
 static std::map<std::string, std::string> vars;
 
 #ifndef OCTAVE_VERSION
@@ -344,9 +360,12 @@
 {
   if (debug)
     std::cout << cmd << std::endl;
+
   int result = system (cmd.c_str ());
+
   if (WIFEXITED (result))
     result = WEXITSTATUS (result);
+
   return result;
 }