summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-04 10:48:30 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-04 10:48:30 +0000
commitce7c1c05779575ecd031a4852baeb232eba4eb4d (patch)
tree24fbad17be46a98b8cc9bf99fb2f38d333adae0e /include
parentb91d5b7958d752f3509ade4bfeaec4700e48c993 (diff)
support nanosec file timestamp on newer Windows
Support nanosec file timestamp on Windows 8 or later. Original patches are written by kubo (Kubo Takehiro). Windows 7 and earlier also supports nanosec file timestamp, but it's too accurate than system time. so, this feature is disabled on such versions. [Feature #13726] this change also includes [Misc #13702] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/win32.h61
1 files changed, 41 insertions, 20 deletions
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index a2ba226b59..82613a866a 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -139,6 +139,13 @@ typedef int clockid_t;
#undef fstat
#ifdef RUBY_EXPORT
#define utime(_p, _t) rb_w32_utime(_p, _t)
+#undef HAVE_UTIMES
+#define HAVE_UTIMES 1
+#define utimes(_p, _t) rb_w32_utimes(_p, _t)
+#undef HAVE_UTIMENSAT
+#define HAVE_UTIMENSAT 1
+#define AT_FDCWD -100
+#define utimensat(_d, _p, _t, _f) rb_w32_utimensat(_d, _p, _t, _f)
#define lseek(_f, _o, _w) _lseeki64(_f, _o, _w)
#define pipe(p) rb_w32_pipe(p)
@@ -151,7 +158,6 @@ typedef int clockid_t;
#define getppid() rb_w32_getppid()
#define sleep(x) rb_w32_Sleep((x)*1000)
#define Sleep(msec) (void)rb_w32_Sleep(msec)
-#define fstati64(fd,st) rb_w32_fstati64(fd,st)
#undef execv
#define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv)
@@ -166,26 +172,39 @@ typedef int clockid_t;
#define unlink(p) rb_w32_unlink(p)
#endif /* RUBY_EXPORT */
+/* same with stati64 except nanosecond timestamps */
+struct stati64ns {
+ _dev_t st_dev;
+ _ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ _dev_t st_rdev;
+ __int64 st_size;
+ __time64_t st_atime;
+ long st_atimensec;
+ __time64_t st_mtime;
+ long st_mtimensec;
+ __time64_t st_ctime;
+ long st_ctimensec;
+};
+
#if SIZEOF_OFF_T == 8
#define off_t __int64
-#define stat stati64
-#define fstat(fd,st) fstati64(fd,st)
-#if !defined(_MSC_VER) || RUBY_MSVCRT_VERSION < 80
-#define stati64 _stati64
-#ifndef _stati64
-#define _stati64(path, st) rb_w32_stati64(path, st)
-#endif
-#else
-#define stati64 _stat64
-#define _stat64(path, st) rb_w32_stati64(path, st)
-#endif
+#define stat stati64ns
+#define HAVE_STRUCT_STAT_ST_ATIMENSEC
+#define HAVE_STRUCT_STAT_ST_MTIMENSEC
+#define HAVE_STRUCT_STAT_ST_CTIMENSEC
+#define fstat(fd,st) rb_w32_fstati64ns(fd,st)
+#define stati64ns(path, st) rb_w32_stati64ns(path, st)
#else
#define stat(path,st) rb_w32_stat(path,st)
#define fstat(fd,st) rb_w32_fstat(fd,st)
extern int rb_w32_stat(const char *, struct stat *);
extern int rb_w32_fstat(int, struct stat *);
#endif
-#define lstat(path,st) rb_w32_lstati64(path,st)
+#define lstat(path,st) rb_w32_lstati64ns(path,st)
#define access(path,mode) rb_w32_access(path,mode)
#define strcasecmp _stricmp
@@ -316,14 +335,14 @@ extern int rb_w32_urmdir(const char *);
extern int rb_w32_unlink(const char *);
extern int rb_w32_uunlink(const char *);
extern int rb_w32_uchmod(const char *, int);
-extern int rb_w32_stati64(const char *, struct stati64 *);
-extern int rb_w32_ustati64(const char *, struct stati64 *);
-extern int rb_w32_lstati64(const char *, struct stati64 *);
-extern int rb_w32_ulstati64(const char *, struct stati64 *);
+extern int rb_w32_stati64ns(const char *, struct stati64ns *);
+extern int rb_w32_ustati64ns(const char *, struct stati64ns *);
+extern int rb_w32_lstati64ns(const char *, struct stati64ns *);
+extern int rb_w32_ulstati64ns(const char *, struct stati64ns *);
extern int rb_w32_access(const char *, int);
extern int rb_w32_uaccess(const char *, int);
extern char rb_w32_fd_is_text(int);
-extern int rb_w32_fstati64(int, struct stati64 *);
+extern int rb_w32_fstati64ns(int, struct stati64ns *);
extern int rb_w32_dup2(int, int);
#include <float.h>
@@ -440,8 +459,6 @@ extern rb_gid_t getegid (void);
extern int setuid (rb_uid_t);
extern int setgid (rb_gid_t);
-extern int fstati64(int, struct stati64 *);
-
extern char *rb_w32_strerror(int);
#ifdef RUBY_EXPORT
@@ -732,6 +749,10 @@ ssize_t rb_w32_read(int, void *, size_t);
ssize_t rb_w32_write(int, const void *, size_t);
int rb_w32_utime(const char *, const struct utimbuf *);
int rb_w32_uutime(const char *, const struct utimbuf *);
+int rb_w32_utimes(const char *, const struct timeval *);
+int rb_w32_uutimes(const char *, const struct timeval *);
+int rb_w32_utimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
+int rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */
int WINAPI rb_w32_Sleep(unsigned long msec);
int rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout);