Merge pull request #101 from hughbe/msvc-cleanup

Fixup some MSVC warnings
diff --git a/lib/BuildSystem/LaneBasedExecutionQueue.cpp b/lib/BuildSystem/LaneBasedExecutionQueue.cpp
index 054a230..8dc1c76 100644
--- a/lib/BuildSystem/LaneBasedExecutionQueue.cpp
+++ b/lib/BuildSystem/LaneBasedExecutionQueue.cpp
@@ -43,9 +43,11 @@
 using namespace llbuild;
 using namespace llbuild::buildsystem;
 
+#if !defined(_WIN32)
 extern "C" {
   extern char **environ;
 }
+#endif
 
 namespace {
 
@@ -324,7 +326,7 @@
     std::vector<const char*> env(environment.size() + 1);
     char* const* envp = nullptr;
     if (environment.empty()) {
-      envp = ::environ;
+      envp = environ;
     } else {
       for (size_t i = 0; i != envStorage.size(); ++i) {
         env[i] = envStorage[i].c_str();
diff --git a/lib/Commands/NinjaBuildCommand.cpp b/lib/Commands/NinjaBuildCommand.cpp
index 5cc52c9..a3e972d 100644
--- a/lib/Commands/NinjaBuildCommand.cpp
+++ b/lib/Commands/NinjaBuildCommand.cpp
@@ -52,9 +52,11 @@
 using namespace llbuild::basic;
 using namespace llbuild::commands;
 
+#if !defined(_WIN32)
 extern "C" {
   extern char **environ;
 }
+#endif
 
 static uint64_t getTimeInMicroseconds() {
   llvm::sys::TimeValue now = llvm::sys::TimeValue::now();
@@ -1042,7 +1044,7 @@
                         ("{ \"name\": \"%s\", \"ph\": \"B\", \"pid\": 0, "
                          "\"tid\": %d, \"ts\": %llu},\n"),
                         localCommand->getEffectiveDescription().c_str(), bucket,
-                        startTime);
+                        static_cast<unsigned long long>(startTime));
               });
           }
 
@@ -1056,7 +1058,7 @@
                         ("{ \"name\": \"%s\", \"ph\": \"E\", \"pid\": 0, "
                          "\"tid\": %d, \"ts\": %llu},\n"),
                         localCommand->getEffectiveDescription().c_str(), bucket,
-                        endTime);
+                        static_cast<unsigned long long>(endTime));
               });
           }
 #endif
@@ -1251,7 +1253,7 @@
 
         if (posix_spawn(&pid, args[0], /*file_actions=*/&fileActions,
                         /*attrp=*/&attributes, const_cast<char**>(args),
-                        ::environ) != 0) {
+                        environ) != 0) {
           context.emitError("unable to spawn process (%s)", strerror(errno));
           return false;
         }
@@ -1941,8 +1943,8 @@
     // FIXME: Do a serious analysis of scheduling, including ideally an active
     // scheduler in the execution queue.
     if (numJobsInParallel == 0) {
-      long numCPUs = sysconf(_SC_NPROCESSORS_ONLN);
-      if (numCPUs < 0) {
+      unsigned numCPUs = std::thread::hardware_concurrency();
+      if (numCPUs == 0) {
         context.emitError("unable to detect number of CPUs (%s)",
                           strerror(errno));
         return 1;