summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2015-11-12 01:19:00 (GMT)
committerEvan Martin <martine@danga.com>2015-11-12 01:19:00 (GMT)
commit4ffe56d387dce2bc5126fc4079ad2f2b31fba30e (patch)
treeb23e4182918a3d35c9f9feb470194c63f4be68f0 /src
parenta65240d52c451f69d9b2f1252738d67eb99a296c (diff)
parentaa14d6e067c6491555150c1f40de1388c3491124 (diff)
downloadNinja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.zip
Ninja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.tar.gz
Ninja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.tar.bz2
Merge pull request #1007 from mikesep/aix
Support for AIX
Diffstat (limited to 'src')
-rw-r--r--src/build_log.cc11
-rw-r--r--src/getopt.c2
-rw-r--r--src/getopt.h2
-rwxr-xr-xsrc/inline.sh2
-rw-r--r--src/ninja.cc3
-rw-r--r--src/ninja_test.cc3
-rw-r--r--src/util.cc12
7 files changed, 31 insertions, 4 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index 589c6da..8a52514 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -12,6 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// On AIX, inttypes.h gets indirectly included by build_log.h.
+// It's easiest just to ask for the printf format macros right away.
+#ifndef _WIN32
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#endif
+
#include "build_log.h"
#include <errno.h>
@@ -19,9 +27,6 @@
#include <string.h>
#ifndef _WIN32
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
#include <inttypes.h>
#include <unistd.h>
#endif
diff --git a/src/getopt.c b/src/getopt.c
index 3350fb9..0c2ef35 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -385,11 +385,13 @@ getopt_internal (int argc, char **argv, char *shortopts,
return optopt;
}
+#ifndef _AIX
int
getopt (int argc, char **argv, char *optstring)
{
return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
}
+#endif
int
getopt_long (int argc, char **argv, const char *shortopts,
diff --git a/src/getopt.h b/src/getopt.h
index b4247fb..965dc29 100644
--- a/src/getopt.h
+++ b/src/getopt.h
@@ -39,7 +39,9 @@ extern "C"
extern int optopt;
/* function prototypes */
+#ifndef _AIX
int getopt (int argc, char **argv, char *optstring);
+#endif
int getopt_long (int argc, char **argv, const char *shortopts,
const GETOPT_LONG_OPTION_T * longopts, int *longind);
int getopt_long_only (int argc, char **argv, const char *shortopts,
diff --git a/src/inline.sh b/src/inline.sh
index 5acc17b..fa282fa 100755
--- a/src/inline.sh
+++ b/src/inline.sh
@@ -20,6 +20,6 @@
varname="$1"
echo "const char $varname[] ="
-od -t x1 -A n -v | sed -e 's| ||g; s|..|\\x&|g; s|^|"|; s|$|"|'
+od -t x1 -A n -v | sed -e 's|[ \t]||g; s|..|\\x&|g; s|^|"|; s|$|"|'
echo ";"
diff --git a/src/ninja.cc b/src/ninja.cc
index fe4a580..21dede6 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -22,6 +22,9 @@
#include "getopt.h"
#include <direct.h>
#include <windows.h>
+#elif defined(_AIX)
+#include "getopt.h"
+#include <unistd.h>
#else
#include <getopt.h>
#include <unistd.h>
diff --git a/src/ninja_test.cc b/src/ninja_test.cc
index 54d8784..11087b6 100644
--- a/src/ninja_test.cc
+++ b/src/ninja_test.cc
@@ -17,6 +17,9 @@
#ifdef _WIN32
#include "getopt.h"
+#elif defined(_AIX)
+#include "getopt.h"
+#include <unistd.h>
#else
#include <getopt.h>
#endif
diff --git a/src/util.cc b/src/util.cc
index aa47f2f..d150fe2 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -45,6 +45,8 @@
#elif defined(__SVR4) && defined(__sun)
#include <unistd.h>
#include <sys/loadavg.h>
+#elif defined(_AIX)
+#include <libperfstat.h>
#elif defined(linux) || defined(__GLIBC__)
#include <sys/sysinfo.h>
#endif
@@ -573,6 +575,16 @@ double GetLoadAverage() {
return posix_compatible_load;
}
+#elif defined(_AIX)
+double GetLoadAverage() {
+ perfstat_cpu_total_t cpu_stats;
+ if (perfstat_cpu_total(NULL, &cpu_stats, sizeof(cpu_stats), 1) < 0) {
+ return -0.0f;
+ }
+
+ // Calculation taken from comment in libperfstats.h
+ return double(cpu_stats.loadavg[0]) / double(1 << SBITS);
+}
#else
double GetLoadAverage() {
double loadavg[3] = { 0.0f, 0.0f, 0.0f };