From ed5e0a6e4127ff0acacef01708d8d9d6ef0d6a34 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Thu, 29 Nov 2012 21:50:45 -0700 Subject: [PATCH] ntdll: Add support for nanosecond precision file times on *BSD. --- configure | 27 +++++++++++++++++++++++++++ configure.ac | 2 +- dlls/ntdll/file.c | 10 ++++++++++ include/config.h.in | 9 +++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b437a78cb66..638ddfbb495 100755 --- a/configure +++ b/configure @@ -14131,6 +14131,15 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi +ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec" "ac_cv_member_struct_stat_st_mtimespec" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_MTIMESPEC 1 +_ACEOF + + fi ac_fn_c_check_member "$LINENO" "struct stat" "st_ctim" "ac_cv_member_struct_stat_st_ctim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_ctim" = xyes; then : @@ -14140,6 +14149,15 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi +ac_fn_c_check_member "$LINENO" "struct stat" "st_ctimespec" "ac_cv_member_struct_stat_st_ctimespec" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_ctimespec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_CTIMESPEC 1 +_ACEOF + + fi ac_fn_c_check_member "$LINENO" "struct stat" "st_atim" "ac_cv_member_struct_stat_st_atim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_atim" = xyes; then : @@ -14149,6 +14167,15 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi +ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec" "ac_cv_member_struct_stat_st_atimespec" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_atimespec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_ATIMESPEC 1 +_ACEOF + + fi diff --git a/configure.ac b/configure.ac index 8e6a70f5421..5d2b4f48f99 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 da5be8e1096..ccf593394ff 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; } diff --git a/include/config.h.in b/include/config.h.in index 4b3a5d22930..f22c5ebc966 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -857,15 +857,24 @@ /* Define to 1 if `st_atim' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_ATIM +/* Define to 1 if `st_atimespec' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_ATIMESPEC + /* Define to 1 if `st_blocks' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLOCKS /* Define to 1 if `st_ctim' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_CTIM +/* Define to 1 if `st_ctimespec' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_CTIMESPEC + /* Define to 1 if `st_mtim' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_MTIM +/* Define to 1 if `st_mtimespec' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_MTIMESPEC + /* Define to 1 if `tcps_connattempt' is a member of `struct tcpstat'. */ #undef HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT