[PATCH 1/2] ntdll: Add support for nanosecond precision file times on *BSD.
Charles Davis
cdavis5x at gmail.com
Thu Nov 29 22:50:45 CST 2012
These are the BSD names for the st_?tim fields. Darwin and NetBSD still
use them, but FreeBSD and OpenBSD have moved to the POSIX standard names
(but retain these for compatibility).
---
configure.ac | 2 +-
dlls/ntdll/file.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 8e6a70f..5d2b4f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2269,7 +2269,7 @@ AC_CHECK_MEMBERS([struct option.name],,,
#endif])
dnl Check for stat.st_blocks and ns-resolved times
-AC_CHECK_MEMBERS([struct stat.st_blocks,struct stat.st_mtim,struct stat.st_ctim,struct stat.st_atim])
+AC_CHECK_MEMBERS([struct stat.st_blocks,struct stat.st_mtim,struct stat.st_mtimespec,struct stat.st_ctim,struct stat.st_ctimespec,struct stat.st_atim,struct stat.st_atimespec])
dnl Check for sin6_scope_id
AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,,
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index da5be8e..ccf5933 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1594,9 +1594,13 @@ static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_
tv[1].tv_sec = st.st_mtime;
#ifdef HAVE_STRUCT_STAT_ST_ATIM
tv[0].tv_usec = st.st_atim.tv_nsec / 1000;
+#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
+ tv[0].tv_usec = st.st_atimespec.tv_nsec / 1000;
#endif
#ifdef HAVE_STRUCT_STAT_ST_MTIM
tv[1].tv_usec = st.st_mtim.tv_nsec / 1000;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ tv[1].tv_usec = st.st_mtimespec.tv_nsec / 1000;
#endif
}
}
@@ -1631,12 +1635,18 @@ static inline void get_file_times( const struct stat *st, LARGE_INTEGER *mtime,
RtlSecondsSince1970ToTime( st->st_atime, atime );
#ifdef HAVE_STRUCT_STAT_ST_MTIM
mtime->QuadPart += st->st_mtim.tv_nsec / 100;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
+ mtime->QuadPart += st->st_mtimespec.tv_nsec / 100;
#endif
#ifdef HAVE_STRUCT_STAT_ST_CTIM
ctime->QuadPart += st->st_ctim.tv_nsec / 100;
+#elif defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
+ ctime->QuadPart += st->st_ctimespec.tv_nsec / 100;
#endif
#ifdef HAVE_STRUCT_STAT_ST_ATIM
atime->QuadPart += st->st_atim.tv_nsec / 100;
+#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
+ atime->QuadPart += st->st_atimespec.tv_nsec / 100;
#endif
*creation = *mtime;
}
--
1.7.12.4
More information about the wine-patches
mailing list