diff options
author | Miguel de Icaza <miguel@gnome.org> | 2018-01-04 12:04:56 +0300 |
---|---|---|
committer | Ludovic Henry <luhenry@microsoft.com> | 2018-01-04 12:04:56 +0300 |
commit | e0e185d70abd73e82bbde7520edcb3bb0c68f1c8 (patch) | |
tree | 7a01dfca28d00f238d9e081302dfd31936ed62bb /support | |
parent | 975765dbabf177958e8c4278811d5947fd302211 (diff) |
Adds support for nanosecond resolution file information where available (Fixes: 6283) (#6307)
* Adds support for nanosecond resolution file information where available.
This patch adds support to the runtime to use the nanosecond
information available on Mac and Linux on `struct stat`.
`stat.st_Xtimespec` strucutre on OSX, and `stat.st_Xtime` and
`stat.st_Xtim.tv_nsec` pair on Linux.
Additionally, this adds support in `Mono.Posix` for MacOS nanosecond stat
data, it already had Linux support before.
* Use ULL here to prevent the computation from overflowing
Diffstat (limited to 'support')
-rw-r--r-- | support/sys-stat.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/support/sys-stat.c b/support/sys-stat.c index d6abce4a1fa..af2731cccbf 100644 --- a/support/sys-stat.c +++ b/support/sys-stat.c @@ -51,16 +51,24 @@ Mono_Posix_FromStat (struct Mono_Posix_Stat *from, void *_to) to->st_atime = from->st_atime_; to->st_mtime = from->st_mtime_; to->st_ctime = from->st_ctime_; -#ifdef HAVE_STRUCT_STAT_ST_ATIM +#if HAVE_STRUCT_STAT_ST_ATIMESPEC + to->st_atimespec.tv_sec = from->st_atime_; + to->st_atimespec.tv_nsec = from->st_atime_nsec; + to->st_mtimespec.tv_sec = from->st_mtime_; + to->st_mtimespec.tv_nsec = from->st_mtime_nsec; + to->st_ctimespec.tv_sec = from->st_ctime_; + to->st_ctimespec.tv_nsec = from->st_ctime_nsec; +#else +# ifdef HAVE_STRUCT_STAT_ST_ATIM to->st_atim.tv_nsec = from->st_atime_nsec; -#endif -#ifdef HAVE_STRUCT_STAT_ST_MTIM +# endif +# ifdef HAVE_STRUCT_STAT_ST_MTIM to->st_mtim.tv_nsec = from->st_mtime_nsec; -#endif -#ifdef HAVE_STRUCT_STAT_ST_CTIM +# endif +# ifdef HAVE_STRUCT_STAT_ST_CTIM to->st_ctim.tv_nsec = from->st_ctime_nsec; +# endif #endif - return 0; } @@ -87,16 +95,21 @@ Mono_Posix_ToStat (void *_from, struct Mono_Posix_Stat *to) to->st_atime_ = from->st_atime; to->st_mtime_ = from->st_mtime; to->st_ctime_ = from->st_ctime; -#ifdef HAVE_STRUCT_STAT_ST_ATIM +#if HAVE_STRUCT_STAT_ST_ATIMESPEC + to->st_atime_nsec = from->st_atimespec.tv_nsec; + to->st_mtime_nsec = from->st_mtimespec.tv_nsec; + to->st_ctime_nsec = from->st_ctimespec.tv_nsec; +#else +# ifdef HAVE_STRUCT_STAT_ST_ATIM to->st_atime_nsec = from->st_atim.tv_nsec; -#endif -#ifdef HAVE_STRUCT_STAT_ST_MTIM +# endif +# ifdef HAVE_STRUCT_STAT_ST_MTIM to->st_mtime_nsec = from->st_mtim.tv_nsec; -#endif -#ifdef HAVE_STRUCT_STAT_ST_CTIM +# endif +# ifdef HAVE_STRUCT_STAT_ST_CTIM to->st_ctime_nsec = from->st_ctim.tv_nsec; +# endif #endif - return 0; } |