Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-06-06 19:35:09 +0400
committerCorinna Vinschen <corinna@vinschen.de>2002-06-06 19:35:09 +0400
commitc4e6ff484c1e6a57304d14ba46852054e98e9158 (patch)
tree2d881cc668e649009946693521b0a9f097dd6060
parenta81cc3be2ab2a194428a4225709b91366511f1f8 (diff)
* fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of
st_atim, st_mtim, and st_ctim fields. * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Ditto. * fhandler_process.cc (fhandler_process::fstat): Ditto. * glob.c (stat32_to_STAT): Copy across the whole st_atim, st_mtime, and st_ctim fields. * syscalls.cc (stat64_to_stat32): Ditto. * times.cc (to_timestruc_t): New function. (time_as_timestruc_t): New function. * winsup.h: Add to_timestruc_t and time_as_timestruc_t functions. * include/cygwin/stat.h: Replace time_t with timestruc_t throughout for all file times, removing the st_spare1, st_spare2, and st_spare3 fields in the process. Add macros to access tv_sec fields by old names. * include/cygwin/types.h: Typedef timespec_t and timestruc_t as struct timespec.
-rw-r--r--winsup/cygwin/ChangeLog19
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc6
-rw-r--r--winsup/cygwin/fhandler_process.cc3
-rw-r--r--winsup/cygwin/glob.c6
-rw-r--r--winsup/cygwin/include/cygwin/stat.h31
-rw-r--r--winsup/cygwin/include/cygwin/types.h2
-rw-r--r--winsup/cygwin/syscalls.cc6
-rw-r--r--winsup/cygwin/times.cc41
-rw-r--r--winsup/cygwin/winsup.h2
10 files changed, 90 insertions, 29 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index d0b81dcaf..fe3e97d89 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+2002-06-05 Conrad Scott <conrad.scott@dsl.pipex.com>
+
+ * fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of
+ st_atim, st_mtim, and st_ctim fields.
+ * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Ditto.
+ * fhandler_process.cc (fhandler_process::fstat): Ditto.
+ * glob.c (stat32_to_STAT): Copy across the whole st_atim,
+ st_mtime, and st_ctim fields.
+ * syscalls.cc (stat64_to_stat32): Ditto.
+ * times.cc (to_timestruc_t): New function.
+ (time_as_timestruc_t): New function.
+ * winsup.h: Add to_timestruc_t and time_as_timestruc_t functions.
+ * include/cygwin/stat.h: Replace time_t with timestruc_t
+ throughout for all file times, removing the st_spare1, st_spare2,
+ and st_spare3 fields in the process. Add macros to access tv_sec
+ fields by old names.
+ * include/cygwin/types.h: Typedef timespec_t and timestruc_t as
+ struct timespec.
+
2002-06-03 Pierre Humblet <pierre.humblet@ieee.org>
* sec_helper.cc (lookup_name): Suppress.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index b3fa13c27..1ccc93d7e 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -842,7 +842,8 @@ fhandler_base::fstat (struct __stat64 *buf, path_conv *)
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;
}
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 4d06a410b..6852d3f02 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -200,9 +200,9 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
&& 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;
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index fca9fd37b..86393db05 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -121,7 +121,8 @@ fhandler_process::fstat (struct __stat64 *buf, path_conv *pc)
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;
diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c
index f1fec9055..971b3092e 100644
--- a/winsup/cygwin/glob.c
+++ b/winsup/cygwin/glob.c
@@ -818,9 +818,9 @@ stat32_to_STAT (struct __stat32 *src, struct STAT *dst)
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;
}
diff --git a/winsup/cygwin/include/cygwin/stat.h b/winsup/cygwin/include/cygwin/stat.h
index 0ac22a679..5772a3754 100644
--- a/winsup/cygwin/include/cygwin/stat.h
+++ b/winsup/cygwin/include/cygwin/stat.h
@@ -27,12 +27,9 @@ struct __stat32
__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 @@ struct __stat64
__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,17 +69,18 @@ struct stat
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
}
#endif
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index 8f9f16105..69bfa2056 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -19,6 +19,8 @@ extern "C"
#include <sys/sysmacros.h>
+typedef struct timespec timespec_t, timestruc_t;
+
typedef long __off32_t;
typedef long long __off64_t;
#ifdef __CYGWIN_USE_BIG_TYPES__
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index ed2e23611..964b82ec7 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1000,9 +1000,9 @@ stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
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;
}
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index e8a886b71..a81201e7b 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -227,6 +227,47 @@ to_time_t (FILETIME *ptr)
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"
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index c153e91b6..2758569a5 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -206,6 +206,8 @@ extern "C" char *__stdcall strcasestr (const char *searchee, const char *lookfor
/* 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 ();