Re: [libcxx] r337960 - [libc++] Use __int128_t to represent file_time_type.
Thank you for the clarification. On Wed, Jul 25, 2018 at 9:16 PM James Y Knight wrote: > As is the case on most modern platforms, the ability to store a high-res > file timestamp is dependent on the filesystem the file is stored on. > > The HFS+ filesystem (used by default before macOS 10.13) stores timestamps > at a 1-second granularity, and APFS (now the default) at a 1 nanosecond > granularity. > > 1-second granularity is also the norm on many of the supported filesystems > on Linux as well. > > On Wed, Jul 25, 2018 at 10:43 PM Eric Fiselier via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Looks like macOS 10.11 only supports a resolution of seconds, but I can't >> find documentation confirming that. >> >> I'll adjust the test. >> >> /Eric >> >> On Wed, Jul 25, 2018 at 8:33 PM Alex L wrote: >> >>> Looks like 'SupportsNanosecondRoundTrip' is set to 0. >>> >>> On 25 July 2018 at 19:30, Alex L wrote: >>> Sure, Standard Error: -- PRIOR:3 AFTER:0 Diff: -return last_write_time(p) == ft; +std::cerr << "PRIOR:" << (long long)ft.time_since_epoch().count() << std::endl; +auto ft2 = last_write_time(p); +std::cerr << "AFTER:" << (long long)ft2.time_since_epoch().count() << std::endl; +return ft2 == ft; On 25 July 2018 at 19:20, Eric Fiselier wrote: > Could you tell me what the value of the initial time point, and the > resulting one are on this line? > > > https://github.com/llvm-mirror/libcxx/blob/master/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp#L224 > > On Wed, Jul 25, 2018 at 8:17 PM Alex L wrote: > >> Please let me know if this information is helpful. If not, I'll mark >> the test as UNSUPPORTED for darwin for the time being and will create an >> internal issue to track the investigation into the OS-specific failure. >> Cheers, >> Alex >> >> On 25 July 2018 at 19:12, Alex L wrote: >> >>> I got the following output on an macOS10.11 machine: >>> >>> Exit Code: 1 >>> >>> Standard Error: >>> >>> -- >>> >>> Test Case = file, epoch_time >>> >>> 0 >>> >>> 0 >>> >>> Test Case = dir, epoch_time >>> >>> 0 >>> >>> 0 >>> >>> Test Case = file, future_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> 15325819240 >>> >>> 1532581924695307000 >>> >>> Test Case = dir, future_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> 15325819240 >>> >>> 1532581924695307000 >>> >>> Test Case = file, past_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> 15325708600 >>> >>> 1532570860695273000 >>> >>> Test Case = dir, past_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> 15325708600 >>> >>> 1532570860695273000 >>> >>> Test Case = file, before_epoch_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> -2230 >>> >>> -22217000 >>> >>> Test Case = dir, before_epoch_time >>> >>> In set_last_write_time_dynamic_env_test():455 Assertion >>> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >>> >>> in file: >>> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >>> >>> >>> >>> -2230 >>> >>> -22217000 >>> >>> Test
Re: [libcxx] r337960 - [libc++] Use __int128_t to represent file_time_type.
As is the case on most modern platforms, the ability to store a high-res file timestamp is dependent on the filesystem the file is stored on. The HFS+ filesystem (used by default before macOS 10.13) stores timestamps at a 1-second granularity, and APFS (now the default) at a 1 nanosecond granularity. 1-second granularity is also the norm on many of the supported filesystems on Linux as well. On Wed, Jul 25, 2018 at 10:43 PM Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Looks like macOS 10.11 only supports a resolution of seconds, but I can't > find documentation confirming that. > > I'll adjust the test. > > /Eric > > On Wed, Jul 25, 2018 at 8:33 PM Alex L wrote: > >> Looks like 'SupportsNanosecondRoundTrip' is set to 0. >> >> On 25 July 2018 at 19:30, Alex L wrote: >> >>> Sure, >>> >>> Standard Error: >>> >>> -- >>> >>> PRIOR:3 >>> >>> AFTER:0 >>> >>> >>> Diff: >>> >>> >>> -return last_write_time(p) == ft; >>> >>> +std::cerr << "PRIOR:" << (long long)ft.time_since_epoch().count() >>> << std::endl; >>> >>> +auto ft2 = last_write_time(p); >>> >>> +std::cerr << "AFTER:" << (long long)ft2.time_since_epoch().count() >>> << std::endl; >>> >>> +return ft2 == ft; >>> >>> On 25 July 2018 at 19:20, Eric Fiselier wrote: >>> Could you tell me what the value of the initial time point, and the resulting one are on this line? https://github.com/llvm-mirror/libcxx/blob/master/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp#L224 On Wed, Jul 25, 2018 at 8:17 PM Alex L wrote: > Please let me know if this information is helpful. If not, I'll mark > the test as UNSUPPORTED for darwin for the time being and will create an > internal issue to track the investigation into the OS-specific failure. > Cheers, > Alex > > On 25 July 2018 at 19:12, Alex L wrote: > >> I got the following output on an macOS10.11 machine: >> >> Exit Code: 1 >> >> Standard Error: >> >> -- >> >> Test Case = file, epoch_time >> >> 0 >> >> 0 >> >> Test Case = dir, epoch_time >> >> 0 >> >> 0 >> >> Test Case = file, future_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> 15325819240 >> >> 1532581924695307000 >> >> Test Case = dir, future_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> 15325819240 >> >> 1532581924695307000 >> >> Test Case = file, past_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> 15325708600 >> >> 1532570860695273000 >> >> Test Case = dir, past_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> 15325708600 >> >> 1532570860695273000 >> >> Test Case = file, before_epoch_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> -2230 >> >> -22217000 >> >> Test Case = dir, before_epoch_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> >> >> -2230 >> >> -22217000 >> >> Test Case = file, just_before_epoch_time >> >> In set_last_write_time_dynamic_env_test():455 Assertion >> TEST_CHECK(CompareTime(got_time, TC.new_time)) failed. >> >> in file: >> /Users/local/llvm/projects/libcxx/test/std/experimental/filesystem/fs.o
[libcxx] r337960 - [libc++] Use __int128_t to represent file_time_type.
Author: ericwf Date: Wed Jul 25 13:51:49 2018 New Revision: 337960 URL: http://llvm.org/viewvc/llvm-project?rev=337960&view=rev Log: [libc++] Use __int128_t to represent file_time_type. Summary: The ``file_time_type`` time point is used to represent the write times for files. Its job is to act as part of a C++ wrapper for less ideal system interfaces. The underlying filesystem uses the ``timespec`` struct for the same purpose. However, the initial implementation of ``file_time_type`` could not represent either the range or resolution of ``timespec``, making it unsuitable. Fixing this requires an implementation which uses more than 64 bits to store the time point. I primarily considered two solutions: Using ``__int128_t`` and using a arithmetic emulation of ``timespec``. Each has its pros and cons, and both come with more than one complication. However, after a lot of consideration, I decided on using `__int128_t`. This patch implements that change. Please see the [FileTimeType Design Document](http://libcxx.llvm.org/docs/DesignDocs/FileTimeType.html) for more information. Reviewers: mclow.lists, ldionne, joerg, arthur.j.odwyer, EricWF Reviewed By: EricWF Subscribers: christof, K-ballo, cfe-commits, BillyONeal Differential Revision: https://reviews.llvm.org/D49774 Added: libcxx/trunk/src/include/apple_availability.h Modified: libcxx/trunk/include/experimental/filesystem libcxx/trunk/src/chrono.cpp libcxx/trunk/src/experimental/filesystem/filesystem_common.h libcxx/trunk/src/experimental/filesystem/operations.cpp libcxx/trunk/test/libcxx/experimental/filesystem/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp libcxx/trunk/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp Modified: libcxx/trunk/include/experimental/filesystem URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=337960&r1=337959&r2=337960&view=diff == --- libcxx/trunk/include/experimental/filesystem (original) +++ libcxx/trunk/include/experimental/filesystem Wed Jul 25 13:51:49 2018 @@ -260,7 +260,37 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM -typedef chrono::time_point file_time_type; +struct _FilesystemClock { +#if !defined(_LIBCPP_HAS_NO_INT128) + typedef __int128_t rep; + typedef nano period; +#else + typedef long long rep; + typedef nano period; +#endif + + typedef chrono::duration duration; + typedef chrono::time_point<_FilesystemClock> time_point; + + static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; + + _LIBCPP_FUNC_VIS static time_point now() noexcept; + + _LIBCPP_INLINE_VISIBILITY + static time_t to_time_t(const time_point& __t) noexcept { +typedef chrono::duration __secs; +return time_t( +chrono::duration_cast<__secs>(__t.time_since_epoch()).count()); + } + + _LIBCPP_INLINE_VISIBILITY + static time_point from_time_t(time_t __t) noexcept { +typedef chrono::duration __secs; +return time_point(__secs(__t)); + } +}; + +typedef chrono::time_point<_FilesystemClock> file_time_type; struct _LIBCPP_TYPE_VIS space_info { Modified: libcxx/trunk/src/chrono.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=337960&r1=337959&r2=337960&view=diff == --- libcxx/trunk/src/chrono.cpp (original) +++ libcxx/trunk/src/chrono.cpp Wed Jul 25 13:51:49 2018 @@ -11,27 +11,10 @@ #include "cerrno"// errno #include "system_error" // __throw_system_error #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME +#include "include/apple_availability.h" -#if (__APPLE__) -#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) -#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 -#define _LIBCXX_USE_CLOCK_GETTIME -#endif -#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) -#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10 -#define _LIBCXX_USE_CLOCK_GETTIME -#endif -#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) -#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10 -#define _LIBCXX_USE_CLOCK_GETTIME -#endif -#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) -#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3 -#define _LIBCXX_USE_CLOCK_GETTIME -#endif -#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ -#else -#define _LIBCXX_USE_CLOCK_GETTIME +#if !defined(__APPLE__) +#define _LIBCPP_USE_CLOCK_GETTIME #endif // __APPLE__ #if defined(_LIBCPP_WIN32API) @@ -42,7 +25,7 @@ #include #endif #else -#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME) +#if !defined(CLOCK_REALTIME) |