summaryrefslogtreecommitdiffstats
path: root/libcxx/include/experimental/filesystem
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-25 20:51:49 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-25 20:51:49 +0000
commitc55ac1055a419eeca16ec885ec2d18c3d4124726 (patch)
tree5d15b9f274079d9faabb11aa7862040109f67ce4 /libcxx/include/experimental/filesystem
parent1d4a78ef042280319f95172a2d1e95558b0ce2ab (diff)
downloadbcm5719-llvm-c55ac1055a419eeca16ec885ec2d18c3d4124726.tar.gz
bcm5719-llvm-c55ac1055a419eeca16ec885ec2d18c3d4124726.zip
[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 llvm-svn: 337960
Diffstat (limited to 'libcxx/include/experimental/filesystem')
-rw-r--r--libcxx/include/experimental/filesystem32
1 files changed, 31 insertions, 1 deletions
diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem
index 060c7e0335b..dbc03595d42 100644
--- a/libcxx/include/experimental/filesystem
+++ b/libcxx/include/experimental/filesystem
@@ -260,7 +260,37 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
-typedef chrono::time_point<std::chrono::system_clock> 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<rep, period> 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<rep> __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<rep> __secs;
+ return time_point(__secs(__t));
+ }
+};
+
+typedef chrono::time_point<_FilesystemClock> file_time_type;
struct _LIBCPP_TYPE_VIS space_info
{
OpenPOWER on IntegriCloud