diff --git a/src/build.cc b/src/build.cc
index 157442d..65df17b 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -18,7 +18,7 @@
 #include <stdio.h>
 
 #ifdef _WIN32
-#include <windows.h>
+//XXX see "subprocess.h" #include <windows.h>
 #else
 #include <unistd.h>
 #include <sys/ioctl.h>
diff --git a/src/build_log.cc b/src/build_log.cc
index 5803ada..8ee4c81 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -153,7 +153,7 @@ class LineReader {
 
  private:
   FILE* file_;
-  char buf_[256 << 10];
+  char buf_[256 << 10]; //FIXME: huge stack! 262144 bytes; ck
   char* buf_end_;  // Points one past the last valid byte in |buf_|.
 
   char* line_start_;
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index 74f33c4..492e8c4 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -12,6 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// If _GNU_SOURCE is defined all the other features are turned on! ck
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for _LARGEFILE64_SOURCE, default on unix!
+#endif
+
 #include "disk_interface.h"
 
 #include <errno.h>
@@ -83,15 +88,27 @@ TimeStamp RealDiskInterface::Stat(const string& path) {
     return -1;
   }
   const FILETIME& filetime = attrs.ftLastWriteTime;
-  // FILETIME is in 100-nanosecond increments since the Windows epoch.
-  // We don't much care about epoch correctness but we do want the
-  // resulting value to fit in an integer.
+  /* A Windows file time is a 64-bit value that represents the number of
+   * 100-nanosecond intervals that have elapsed since
+   * 12:00 midnight, January 1, 1601 A.D. (C.E.)
+   * Coordinated Universal Time (UTC). */
   uint64_t mtime = ((uint64_t)filetime.dwHighDateTime << 32) |
     ((uint64_t)filetime.dwLowDateTime);
-  mtime /= 1000000000LL / 100; // 100ns -> s.
+
+#ifdef USE_TIME_T
+  // We don't much care about epoch correctness but we do want the
+  // resulting value to fit in an integer.
+  mtime /= 1000000000LL / 100LL; // 100ns -> s.
   mtime -= 12622770400LL;  // 1600 epoch -> 2000 epoch (subtract 400 years).
   return (TimeStamp)mtime;
 #else
+  // return the time as a signed quadword, but keep 100nsec pression! ck
+  return mtime;
+#endif
+
+#else
+
+#ifdef USE_TIME_T
   struct stat st;
   if (stat(path.c_str(), &st) < 0) {
     if (errno == ENOENT || errno == ENOTDIR)
@@ -100,6 +117,29 @@ TimeStamp RealDiskInterface::Stat(const string& path) {
     return -1;
   }
   return st.st_mtime;
+#else
+#ifdef __CYGWIN__
+#define stat64 stat
+#endif
+  struct stat64 st;
+  if (stat64(path.c_str(), &st) < 0) {
+    if (errno == ENOENT || errno == ENOTDIR)
+      return 0;
+    Error("stat64(%s): %s", path.c_str(), strerror(errno));
+    return -1;
+  }
+  // use 100 nsec ticks like windows
+#ifdef __APPLE__
+  return (((int64_t) st.st_mtimespec.tv_sec) * 10000000LL) + (st.st_mtimespec.tv_nsec / 100LL);
+#elif defined(_LARGEFILE64_SOURCE)
+  return (((int64_t) st.st_mtim.tv_sec) * 10000000LL) + (st.st_mtim.tv_nsec / 100LL);
+#else
+#warning "NO tv_nsec available with stat()!"
+  // see http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html
+  return (((int64_t) st.st_mtime) * 10000000LL); //XXX + (st.st_mtime_nsec / 100LL);
+#endif
+#endif  // USE_TIME_T
+
 #endif
 }
 
diff --git a/src/getopt.c b/src/getopt.c
index 1e3c09d..fdb5e1d 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -92,7 +92,7 @@ gpietsch@comcast.net
 #endif
 
 #ifdef _WIN32
-#pragma warning(disable: 4701)
+//FIXME #pragma warning(disable: 4701)  // Potentially uninitialized local variable 'name' used
 #endif
 
 /* macros */
@@ -159,7 +159,7 @@ getopt_internal (int argc, char **argv, char *shortopts,
   char *possible_arg = NULL;
   int longopt_match = -1;
   int has_arg = -1;
-  char *cp;
+  char *cp = NULL;
   int arg_next = 0;
 
   /* first, deal with silly parameters and easy stuff */
@@ -255,7 +255,7 @@ getopt_internal (int argc, char **argv, char *shortopts,
                       longopts[optindex].name, match_chars) == 0)
             {
               /* do we have an exact match? */
-              if (match_chars == (int) (strlen (longopts[optindex].name)))
+              if (match_chars == strlen (longopts[optindex].name))
                 {
                   longopt_match = optindex;
                   break;
diff --git a/src/graph.cc b/src/graph.cc
index 3531e86..7851f60 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -144,7 +144,8 @@ bool Edge::RecomputeOutputDirty(BuildLog* build_log,
         return true;
       }
     } else {
-      EXPLAIN("output %s older than most recent input %s (%d vs %d)",
+      //FIXME #ifdef USE_TIME_T ...
+      EXPLAIN("output %s older than most recent input %s (%016lld vs %016lld)",
           output->path().c_str(),
           most_recent_node ? most_recent_node->path().c_str() : "",
           output->mtime(), most_recent_input);
diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc
index 3484e5f..58d3e42 100644
--- a/src/subprocess-win32.cc
+++ b/src/subprocess-win32.cc
@@ -44,7 +44,7 @@ Subprocess::~Subprocess() {
 HANDLE Subprocess::SetupPipe(HANDLE ioport) {
   char pipe_name[100];
   snprintf(pipe_name, sizeof(pipe_name),
-           "\\\\.\\pipe\\ninja_pid%u_sp%p", GetCurrentProcessId(), this);
+           "\\\\.\\pipe\\ninja_pid%lu_sp%p", GetCurrentProcessId(), this);
 
   pipe_ = ::CreateNamedPipeA(pipe_name,
                              PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
diff --git a/src/subprocess.h b/src/subprocess.h
index 4c1629c..59037d9 100644
--- a/src/subprocess.h
+++ b/src/subprocess.h
@@ -21,6 +21,8 @@
 using namespace std;
 
 #ifdef _WIN32
+// from http://stackoverflow.com/questions/9643182/win32-api-functions-not-found
+#define WINVER 0x0501   // at least XP SP1 API for GetProcessId needed
 #include <windows.h>
 #else
 #include <signal.h>
diff --git a/src/timestamp.h b/src/timestamp.h
index cee7ba8..62d6aa9 100644
--- a/src/timestamp.h
+++ b/src/timestamp.h
@@ -15,10 +15,24 @@
 #ifndef NINJA_TIMESTAMP_H_
 #define NINJA_TIMESTAMP_H_
 
+#ifdef _WIN32
+#include "win32port.h"
+#else
+#include <stdint.h>
+#endif
+
 // When considering file modification times we only care to compare
 // them against one another -- we never convert them to an absolute
-// real time.  On POSIX we use time_t (seconds since epoch) and on
+// real time.
+
+#ifdef USE_TIME_T
+#include <time.h>
+
+// On POSIX we use time_t (seconds since epoch) and on
 // Windows we use a different value.  Both fit in an int.
-typedef int TimeStamp;
+typedef time_t TimeStamp;
+#else
+typedef int64_t TimeStamp;  // as 100ns value!
+#endif
 
 #endif  // NINJA_TIMESTAMP_H_
diff --git a/src/util.cc b/src/util.cc
index d8d7fb3..ac3cdb2 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -293,7 +293,7 @@ string StripAnsiEscapeCodes(const string& in) {
   return stripped;
 }
 
-#ifdef _WIN32
+#if defined _WIN32 || defined __CYGWIN__
 static double GetLoadAverage_win32()
 {
   // TODO(nicolas.despres@gmail.com): Find a way to implement it on Windows.
@@ -315,9 +315,10 @@ static double GetLoadAverage_unix()
 
 double GetLoadAverage()
 {
-#ifdef _WIN32
+#if defined _WIN32 || defined __CYGWIN__
   return GetLoadAverage_win32();
 #else
   return GetLoadAverage_unix();
 #endif // _WIN32
 }
+
