Index: winsup/cygwin/fhandler.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v
retrieving revision 1.127
diff -u -u -r1.127 fhandler.cc
--- winsup/cygwin/fhandler.cc	5 Jun 2002 04:01:42 -0000	1.127
+++ winsup/cygwin/fhandler.cc	6 Jun 2002 00:12:52 -0000
@@ -842,7 +842,8 @@
   buf->st_mode |= get_device () == FH_FLOPPY ? S_IFBLK : S_IFCHR;
   buf->st_nlink = 1;
   buf->st_blksize = S_BLKSIZE;
-  buf->st_atime = buf->st_mtime = buf->st_ctime = time (NULL) - 1;
+  time_as_timestruc_t (&buf->st_ctim);
+  buf->st_atim = buf->st_mtim = buf->st_ctim;
   return 0;
 }
 
Index: winsup/cygwin/fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.23
diff -u -u -r1.23 fhandler_disk_file.cc
--- winsup/cygwin/fhandler_disk_file.cc	5 Jun 2002 01:42:28 -0000	1.23
+++ winsup/cygwin/fhandler_disk_file.cc	6 Jun 2002 00:12:52 -0000
@@ -200,9 +200,9 @@
       && ftCreationTime.dwHighDateTime == 0)
     ftCreationTime = ftLastWriteTime;
 
-  buf->st_atime   = to_time_t (&ftLastAccessTime);
-  buf->st_mtime   = to_time_t (&ftLastWriteTime);
-  buf->st_ctime   = to_time_t (&ftCreationTime);
+  to_timestruc_t (&ftLastAccessTime, &buf->st_atim);
+  to_timestruc_t (&ftLastWriteTime, &buf->st_mtim);
+  to_timestruc_t (&ftCreationTime, &buf->st_ctim);
   buf->st_nlink   = nNumberOfLinks;
   buf->st_dev     = pc->volser ();
   buf->st_size    = ((__off64_t)nFileSizeHigh << 32) + nFileSizeLow;
Index: winsup/cygwin/fhandler_process.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_process.cc,v
retrieving revision 1.13
diff -u -u -r1.13 fhandler_process.cc
--- winsup/cygwin/fhandler_process.cc	5 Jun 2002 01:42:28 -0000	1.13
+++ winsup/cygwin/fhandler_process.cc	6 Jun 2002 00:12:52 -0000
@@ -121,7 +121,8 @@
       return 0;
     case 2:
       buf->st_ctime = buf->st_mtime = p->start_time;
-      buf->st_atime = time(NULL);
+      buf->st_ctim.tv_nsec = buf->st_mtim.tv_nsec = 0;
+      time_as_timestruc_t(&buf->st_atim);
       buf->st_uid = p->uid;
       buf->st_gid = p->gid;
       buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
Index: winsup/cygwin/glob.c
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/glob.c,v
retrieving revision 1.11
diff -u -u -r1.11 glob.c
--- winsup/cygwin/glob.c	15 Mar 2002 10:12:30 -0000	1.11
+++ winsup/cygwin/glob.c	6 Jun 2002 00:12:52 -0000
@@ -818,9 +818,9 @@
   dst->st_gid = src->st_gid;
   dst->st_rdev = src->st_rdev;
   dst->st_size = src->st_size;
-  dst->st_atime = src->st_atime;
-  dst->st_mtime = src->st_mtime;
-  dst->st_ctime = src->st_ctime;
+  dst->st_atim = src->st_atim;
+  dst->st_mtim = src->st_mtim;
+  dst->st_ctim = src->st_ctim;
   dst->st_blksize = src->st_blksize;
   dst->st_blocks = src->st_blocks;
 }
Index: winsup/cygwin/syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.199
diff -u -u -r1.199 syscalls.cc
--- winsup/cygwin/syscalls.cc	5 Jun 2002 16:01:55 -0000	1.199
+++ winsup/cygwin/syscalls.cc	6 Jun 2002 00:12:57 -0000
@@ -1000,9 +1000,9 @@
   dst->st_gid = src->st_gid;
   dst->st_rdev = src->st_rdev;
   dst->st_size = src->st_size;
-  dst->st_atime = src->st_atime;
-  dst->st_mtime = src->st_mtime;
-  dst->st_ctime = src->st_ctime;
+  dst->st_atim = src->st_atim;
+  dst->st_mtim = src->st_mtim;
+  dst->st_ctim = src->st_ctim;
   dst->st_blksize = src->st_blksize;
   dst->st_blocks = src->st_blocks;
 }
Index: winsup/cygwin/times.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/times.cc,v
retrieving revision 1.34
diff -u -u -r1.34 times.cc
--- winsup/cygwin/times.cc	2 Jun 2002 06:07:01 -0000	1.34
+++ winsup/cygwin/times.cc	6 Jun 2002 00:12:57 -0000
@@ -233,6 +233,47 @@
   return x;
 }
 
+/* Cygwin internal */
+/* Convert a Win32 time to "UNIX" timestruc_t format. */
+void __stdcall
+to_timestruc_t (FILETIME *ptr, timestruc_t *out)
+{
+  /* A file time is the number of 100ns since jan 1 1601
+     stuffed into two long words.
+     A timestruc_t is the number of seconds and microseconds since jan 1 1970
+     stuffed into a time_t and a long.  */
+
+  long rem;
+  long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned)ptr->dwLowDateTime);
+
+  /* pass "no time" as epoch */
+  if (x == 0)
+    {
+      out->tv_sec = 0;
+      out->tv_nsec = 0;
+      return;
+    }
+
+  x -= FACTOR;			/* number of 100ns between 1601 and 1970 */
+  rem = x % ((long long)NSPERSEC);
+  x /= (long long) NSPERSEC;		/* number of 100ns in a second */
+  out->tv_nsec = rem * 100;	/* as tv_nsec is in nanoseconds */
+  out->tv_sec = x;
+}
+
+/* Cygwin internal */
+/* Get the current time as a "UNIX" timestruc_t format. */
+void __stdcall
+time_as_timestruc_t (timestruc_t * out)
+{
+  SYSTEMTIME systemtime;
+  FILETIME filetime;
+
+  GetSystemTime (&systemtime);
+  SystemTimeToFileTime (&systemtime, &filetime);
+  to_timestruc_t (&filetime, out);
+}
+
 /* time: POSIX 4.5.1.1, C 4.12.2.4 */
 /* Return number of seconds since 00:00 UTC on jan 1, 1970 */
 extern "C"
Index: winsup/cygwin/winsup.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
retrieving revision 1.92
diff -u -u -r1.92 winsup.h
--- winsup/cygwin/winsup.h	29 May 2002 15:04:27 -0000	1.92
+++ winsup/cygwin/winsup.h	6 Jun 2002 00:12:57 -0000
@@ -206,6 +206,8 @@
 /* Time related */
 void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
 long __stdcall to_time_t (FILETIME * ptr);
+void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out);
+void __stdcall time_as_timestruc_t (timestruc_t * out);
 
 void __stdcall set_console_title (char *);
 void early_stuff_init ();
Index: winsup/cygwin/include/cygwin/stat.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stat.h,v
retrieving revision 1.3
diff -u -u -r1.3 stat.h
--- winsup/cygwin/include/cygwin/stat.h	3 Jun 2002 17:44:09 -0000	1.3
+++ winsup/cygwin/include/cygwin/stat.h	6 Jun 2002 00:12:57 -0000
@@ -27,12 +27,9 @@
   __gid16_t     st_gid;
   __dev16_t     st_rdev;
   __off32_t     st_size;
-  time_t        st_atime;
-  long          st_spare1;
-  time_t        st_mtime;
-  long          st_spare2;
-  time_t        st_ctime;
-  long          st_spare3;
+  timestruc_t   st_atim;
+  timestruc_t   st_mtim;
+  timestruc_t   st_ctim;
   blksize_t     st_blksize;
   __blkcnt32_t  st_blocks;
   long          st_spare4[2];
@@ -48,12 +45,9 @@
   __gid32_t     st_gid;
   __dev32_t     st_rdev;
   __off64_t     st_size;
-  time_t        st_atime;
-  long          st_spare1;
-  time_t        st_mtime;
-  long          st_spare2;
-  time_t        st_ctime;
-  long          st_spare3;
+  timestruc_t   st_atim;
+  timestruc_t   st_mtim;
+  timestruc_t   st_ctim;
   blksize_t     st_blksize;
   __blkcnt64_t  st_blocks;
   long          st_spare4[2];
@@ -75,16 +69,17 @@
   gid_t         st_gid;
   dev_t         st_rdev;
   off_t         st_size;
-  time_t        st_atime;
-  long          st_spare1;
-  time_t        st_mtime;
-  long          st_spare2;
-  time_t        st_ctime;
-  long          st_spare3;
+  timestruc_t   st_atim;
+  timestruc_t   st_mtim;
+  timestruc_t   st_ctim;
   blksize_t     st_blksize;
   blkcnt_t      st_blocks;
   long          st_spare4[2];
 };
+
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
 
 #ifdef __cplusplus
 }
