summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--]src/build_log.cc2
-rwxr-xr-x[-rw-r--r--]src/build_log_test.cc11
-rwxr-xr-x[-rw-r--r--]src/ninja_test.cc2
-rwxr-xr-x[-rw-r--r--]src/util.cc3
-rwxr-xr-x[-rw-r--r--]src/util.h4
5 files changed, 20 insertions, 2 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index 3073f7f..8c45c77 100644..100755
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -54,7 +54,7 @@ bool BuildLog::OpenForWrite(const string& path, string* err) {
*err = strerror(errno);
return false;
}
- setvbuf(log_file_, NULL, _IOLBF, 0);
+ setvbuf(log_file_, NULL, _IOLBF, BUFSIZ);
if (ftell(log_file_) == 0) {
if (fwrite(kFileSignature, sizeof(kFileSignature) - 1, 1, log_file_) < 1) {
diff --git a/src/build_log_test.cc b/src/build_log_test.cc
index 8bb2bfa..1df28db 100644..100755
--- a/src/build_log_test.cc
+++ b/src/build_log_test.cc
@@ -16,6 +16,10 @@
#include "test.h"
+#ifdef WIN32
+#include <fcntl.h>
+#endif
+
static const char kTestFilename[] = "BuildLogTest-tempfile";
struct BuildLogTest : public StateTestWithBuiltinRules {
@@ -90,7 +94,14 @@ TEST_F(BuildLogTest, Truncate) {
// For all possible truncations of the input file, assert that we don't
// crash or report an error when parsing.
for (off_t size = statbuf.st_size; size > 0; --size) {
+#ifndef WIN32
ASSERT_EQ(0, truncate(kTestFilename, size));
+#else
+ int fh;
+ ASSERT_EQ(0, _sopen_s(&fh, kTestFilename, _O_RDWR | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE));
+ ASSERT_EQ(0, _chsize(fh, size));
+ _close(fh);
+#endif
BuildLog log2;
EXPECT_TRUE(log2.Load(kTestFilename, &err));
diff --git a/src/ninja_test.cc b/src/ninja_test.cc
index 6e3f549..a5ef3ab 100644..100755
--- a/src/ninja_test.cc
+++ b/src/ninja_test.cc
@@ -217,7 +217,7 @@ TEST_F(StatTest, Middle) {
#ifndef _mktemp_s
/// mingw has no mktemp. Implement one with the same type as the one
/// found in the Windows API.
-int _mktemp_s(const char* templ) {
+int _mktemp_s(char* templ) {
char* ofs = strchr(templ, 'X');
sprintf(ofs, "%d", rand() % 1000000);
return 0;
diff --git a/src/util.cc b/src/util.cc
index 14b3379..d5a8f1f 100644..100755
--- a/src/util.cc
+++ b/src/util.cc
@@ -25,7 +25,10 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+
+#ifndef _WIN32
#include <sys/time.h>
+#endif
#include <vector>
diff --git a/src/util.h b/src/util.h
index 794177d..c9e06f4 100644..100755
--- a/src/util.h
+++ b/src/util.h
@@ -46,4 +46,8 @@ int ReadFile(const string& path, string* contents, string* err);
/// time.
int64_t GetTimeMillis();
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
#endif // NINJA_UTIL_H_