| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___CHRONO_FILE_CLOCK_H |
| 11 | #define _LIBCPP___CHRONO_FILE_CLOCK_H |
| 12 | |
| 13 | #include <__chrono/duration.h> |
| 14 | #include <__chrono/system_clock.h> |
| 15 | #include <__chrono/time_point.h> |
| 16 | #include <__config> |
| 17 | #include <ratio> |
| 18 | |
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header |
| 21 | #endif |
| 22 | |
| 23 | #ifndef _LIBCPP_CXX03_LANG |
| 24 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 25 | struct _FilesystemClock; |
| 26 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 27 | #endif // !_LIBCPP_CXX03_LANG |
| 28 | |
| 29 | #if _LIBCPP_STD_VER >= 20 |
| 30 | |
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | |
| 33 | namespace chrono { |
| 34 | |
| 35 | // [time.clock.file], type file_clock |
| 36 | using file_clock = filesystem::_FilesystemClock; |
| 37 | |
| 38 | template <class _Duration> |
| 39 | using file_time = time_point<file_clock, _Duration>; |
| 40 | |
| 41 | } // namespace chrono |
| 42 | |
| 43 | _LIBCPP_END_NAMESPACE_STD |
| 44 | |
| 45 | #endif // _LIBCPP_STD_VER >= 20 |
| 46 | |
| 47 | #ifndef _LIBCPP_CXX03_LANG |
| 48 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 49 | struct _FilesystemClock { |
| 50 | # if _LIBCPP_HAS_INT128 |
| 51 | typedef __int128_t rep; |
| 52 | typedef nano period; |
| 53 | # else |
| 54 | typedef long long rep; |
| 55 | typedef nano period; |
| 56 | # endif |
| 57 | |
| 58 | typedef chrono::duration<rep, period> duration; |
| 59 | typedef chrono::time_point<_FilesystemClock> time_point; |
| 60 | |
| 61 | _LIBCPP_EXPORTED_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false; |
| 62 | |
| 63 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI static time_point now() noexcept; |
| 64 | |
| 65 | # if _LIBCPP_STD_VER >= 20 |
| 66 | template <class _Duration> |
| 67 | _LIBCPP_HIDE_FROM_ABI static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { |
| 68 | return chrono::sys_time<_Duration>(__t.time_since_epoch()); |
| 69 | } |
| 70 | |
| 71 | template <class _Duration> |
| 72 | _LIBCPP_HIDE_FROM_ABI static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) { |
| 73 | return chrono::file_time<_Duration>(__t.time_since_epoch()); |
| 74 | } |
| 75 | # endif // _LIBCPP_STD_VER >= 20 |
| 76 | }; |
| 77 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 78 | #endif // !_LIBCPP_CXX03_LANG |
| 79 | |
| 80 | #endif // _LIBCPP___CHRONO_FILE_CLOCK_H |
| 81 |