From 6e04a1e8a6b38b123bbb98e38ff236b4a27d62cb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Dec 2015 18:59:56 +0200 Subject: Prevent signature clashes in nsec() overload set --- butl/filesystem.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'butl') diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx index 5a43cd2..99417b1 100644 --- a/butl/filesystem.cxx +++ b/butl/filesystem.cxx @@ -140,28 +140,34 @@ namespace butl return r; } - // Figuring out whether we have the nanoseconds in some form. + // Figuring out whether we have the nanoseconds in struct stat. Some + // platforms (e.g., FreeBSD), may provide some "compatibility" #define's, + // so use the second argument to not end up with the same signatures. // template - inline constexpr auto nsec (const S* s) -> decltype(s->st_mtim.tv_nsec) + inline constexpr auto + nsec (const S* s, bool) -> decltype(s->st_mtim.tv_nsec) { return s->st_mtim.tv_nsec; // POSIX (GNU/Linux, Solaris). } template - inline constexpr auto nsec (const S* s) -> decltype(s->st_mtimespec.tv_nsec) + inline constexpr auto + nsec (const S* s, int) -> decltype(s->st_mtimespec.tv_nsec) { - return s->st_mtimespec.tv_nsec; // MacOS X. + return s->st_mtimespec.tv_nsec; // *BSD, MacOS. } template - inline constexpr auto nsec (const S* s) -> decltype(s->st_mtime_n) + inline constexpr auto + nsec (const S* s, float) -> decltype(s->st_mtime_n) { return s->st_mtime_n; // AIX 5.2 and later. } template - inline constexpr int nsec (...) {return 0;} + inline constexpr int + nsec (...) {return 0;} timestamp file_mtime (const path& p) @@ -178,7 +184,7 @@ namespace butl return S_ISREG (s.st_mode) ? system_clock::from_time_t (s.st_mtime) + chrono::duration_cast ( - chrono::nanoseconds (nsec (&s))) + chrono::nanoseconds (nsec (&s, true))) : timestamp_nonexistent; } -- cgit v1.1