Skip to content

Commit

Permalink
windows: use _WIN32 define everywhere
Browse files Browse the repository at this point in the history
Rather than mixing use of WIN32 and _WIN32.
  • Loading branch information
evmar committed Jan 22, 2012
1 parent 2ef3a54 commit faac236
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def run(*args, **kwargs):

vcdir = os.environ.get('VCINSTALLDIR')
if vcdir:
args = [os.path.join(vcdir, 'bin', 'cl.exe'), '/nologo', '/EHsc', '/DWIN32']
args = [os.path.join(vcdir, 'bin', 'cl.exe'), '/nologo', '/EHsc']
else:
args = shlex.split(os.environ.get('CXX', 'g++'))
args.extend(['-Wno-deprecated',
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def binary(name):
if platform == 'windows':
cflags = ['/nologo', '/Zi', '/W4', '/WX', '/wd4530', '/wd4100', '/wd4706',
'/wd4512', '/wd4800', '/wd4702',
'/D_CRT_SECURE_NO_WARNINGS', '/DWIN32',
'/D_CRT_SECURE_NO_WARNINGS',
"/DNINJA_PYTHON=\"%s\"" % (options.with_python,)]
ldflags = ['/DEBUG', '/libpath:$builddir']
if not options.debug:
Expand Down
4 changes: 2 additions & 2 deletions src/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ BuildStatus::BuildStatus(const BuildConfig& config)
start_time_millis_(GetTimeMillis()),
last_update_millis_(start_time_millis_),
started_edges_(0), finished_edges_(0), total_edges_(0) {
#ifndef WIN32
#ifndef _WIN32
const char* term = getenv("TERM");
smart_terminal_ = isatty(1) && term && string(term) != "dumb";
#else
Expand Down Expand Up @@ -171,7 +171,7 @@ void BuildStatus::PrintStatus(Edge* edge) {

int progress_chars = printf("[%d/%d] ", started_edges_, total_edges_);

#ifndef WIN32
#ifndef _WIN32
if (smart_terminal_ && !force_full_command) {
// Limit output to width of the terminal if provided so we don't cause
// line-wrapping.
Expand Down
4 changes: 2 additions & 2 deletions src/build_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "test.h"

#ifdef WIN32
#ifdef _WIN32
#include <fcntl.h>
#include <share.h>
#endif
Expand Down Expand Up @@ -102,7 +102,7 @@ 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
#ifndef _WIN32
ASSERT_EQ(0, truncate(kTestFilename, size));
#else
int fh;
Expand Down
4 changes: 2 additions & 2 deletions src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ TEST_F(BuildTest, MissingTarget) {
TEST_F(BuildTest, MakeDirs) {
string err;

#ifdef WIN32
#ifdef _WIN32
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, "build subdir\\dir2\\file: cat in1\n"));
EXPECT_TRUE(builder_.AddTarget("subdir\\dir2\\file", &err));
#else
Expand All @@ -432,7 +432,7 @@ TEST_F(BuildTest, MakeDirs) {
ASSERT_EQ("", err);
ASSERT_EQ(2u, fs_.directories_made_.size());
EXPECT_EQ("subdir", fs_.directories_made_[0]);
#ifdef WIN32
#ifdef _WIN32
EXPECT_EQ("subdir\\dir2", fs_.directories_made_[1]);
#else
EXPECT_EQ("subdir/dir2", fs_.directories_made_[1]);
Expand Down
8 changes: 4 additions & 4 deletions src/disk_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <string.h>
#include <sys/stat.h>

#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#endif

Expand All @@ -28,7 +28,7 @@
namespace {

string DirName(const string& path) {
#ifdef WIN32
#ifdef _WIN32
const char kPathSeparator = '\\';
#else
const char kPathSeparator = '/';
Expand Down Expand Up @@ -66,8 +66,8 @@ bool DiskInterface::MakeDirs(const string& path) {
// RealDiskInterface -----------------------------------------------------------

TimeStamp RealDiskInterface::Stat(const string& path) {
#ifdef WIN32
WIN32_FILE_ATTRIBUTE_DATA attrs;
#ifdef _WIN32
_WIN32_FILE_ATTRIBUTE_DATA attrs;
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &attrs)) {
DWORD err = GetLastError();
if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions src/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdio.h>
#include <string.h>

#ifndef WIN32
#ifndef _WIN32
#include <sys/time.h>
#else
#include <windows.h>
Expand All @@ -30,7 +30,7 @@ Metrics* g_metrics = NULL;

namespace {

#ifndef WIN32
#ifndef _WIN32
/// Compute a platform-specific high-res timer value that fits into an int64.
int64_t HighResTimer() {
timeval tv;
Expand Down
10 changes: 5 additions & 5 deletions src/ninja.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <sys/sysinfo.h>
#endif

#ifdef WIN32
#ifdef _WIN32
#include "getopt.h"
#include <direct.h>
#include <windows.h>
Expand Down Expand Up @@ -107,7 +107,7 @@ int GuessParallelism() {
NULL, 0) < 0) {
processors = 1;
}
#elif defined(WIN32)
#elif defined(_WIN32)
SYSTEM_INFO info;
GetSystemInfo(&info);
processors = info.dwNumberOfProcessors;
Expand Down Expand Up @@ -255,7 +255,7 @@ int ToolQuery(Globals* globals, int argc, char* argv[]) {
return 0;
}

#if !defined(WIN32) && !defined(NINJA_BOOTSTRAP)
#if !defined(_WIN32) && !defined(NINJA_BOOTSTRAP)
int ToolBrowse(Globals* globals, int argc, char* argv[]) {
if (argc < 1) {
Error("expected a target to browse");
Expand All @@ -265,7 +265,7 @@ int ToolBrowse(Globals* globals, int argc, char* argv[]) {
// If we get here, the browse failed.
return 1;
}
#endif // WIN32
#endif // _WIN32

int ToolTargetsList(const vector<Node*>& nodes, int depth, int indent) {
for (vector<Node*>::const_iterator n = nodes.begin();
Expand Down Expand Up @@ -475,7 +475,7 @@ int RunTool(const string& tool, Globals* globals, int argc, char** argv) {
const char* desc;
ToolFunc func;
} tools[] = {
#if !defined(WIN32) && !defined(NINJA_BOOTSTRAP)
#if !defined(_WIN32) && !defined(NINJA_BOOTSTRAP)
{ "browse", "browse dependency graph in a web browser",
ToolBrowse },
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ char* mkdtemp(char* name_template) {

return name_template;
}
#endif // WIN32
#endif // _WIN32

string GetSystemTempDir() {
#ifdef _WIN32
Expand Down
4 changes: 2 additions & 2 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Fatal(const char* msg, ...) {
vfprintf(stderr, msg, ap);
va_end(ap);
fprintf(stderr, "\n");
#ifdef WIN32
#ifdef _WIN32
// On Windows, some tools may inject extra threads.
// exit() may block on locks held by those threads, so forcibly exit.
fflush(stderr);
Expand Down Expand Up @@ -235,7 +235,7 @@ const char* SpellcheckString(const string& text, ...) {
return SpellcheckStringV(text, words);
}

#ifdef WIN32
#ifdef _WIN32
string GetLastErrorString() {
DWORD err = GetLastError();

Expand Down
2 changes: 1 addition & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define NINJA_UTIL_H_
#pragma once

#ifdef WIN32
#ifdef _WIN32
#include "win32port.h"
#else
#include <stdint.h>
Expand Down

0 comments on commit faac236

Please sign in to comment.