xref: /freebsd-src/contrib/llvm-project/libcxx/include/__chrono/file_clock.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
104eeddc0SDimitry Andric // -*- C++ -*-
204eeddc0SDimitry Andric //===----------------------------------------------------------------------===//
304eeddc0SDimitry Andric //
404eeddc0SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
504eeddc0SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
604eeddc0SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
704eeddc0SDimitry Andric //
804eeddc0SDimitry Andric //===----------------------------------------------------------------------===//
904eeddc0SDimitry Andric 
1004eeddc0SDimitry Andric #ifndef _LIBCPP___CHRONO_FILE_CLOCK_H
1104eeddc0SDimitry Andric #define _LIBCPP___CHRONO_FILE_CLOCK_H
1204eeddc0SDimitry Andric 
1304eeddc0SDimitry Andric #include <__chrono/duration.h>
1404eeddc0SDimitry Andric #include <__chrono/system_clock.h>
1504eeddc0SDimitry Andric #include <__chrono/time_point.h>
1604eeddc0SDimitry Andric #include <__config>
1704eeddc0SDimitry Andric #include <ratio>
1804eeddc0SDimitry Andric 
1904eeddc0SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2004eeddc0SDimitry Andric #  pragma GCC system_header
2104eeddc0SDimitry Andric #endif
2204eeddc0SDimitry Andric 
2304eeddc0SDimitry Andric #ifndef _LIBCPP_CXX03_LANG
2404eeddc0SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
2504eeddc0SDimitry Andric struct _FilesystemClock;
2604eeddc0SDimitry Andric _LIBCPP_END_NAMESPACE_FILESYSTEM
2704eeddc0SDimitry Andric #endif // !_LIBCPP_CXX03_LANG
2804eeddc0SDimitry Andric 
2906c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
3004eeddc0SDimitry Andric 
3104eeddc0SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
3204eeddc0SDimitry Andric 
33*cb14a3feSDimitry Andric namespace chrono {
3404eeddc0SDimitry Andric 
3504eeddc0SDimitry Andric // [time.clock.file], type file_clock
365f757f3fSDimitry Andric using file_clock = filesystem::_FilesystemClock;
3704eeddc0SDimitry Andric 
3804eeddc0SDimitry Andric template <class _Duration>
3904eeddc0SDimitry Andric using file_time = time_point<file_clock, _Duration>;
4004eeddc0SDimitry Andric 
4104eeddc0SDimitry Andric } // namespace chrono
4204eeddc0SDimitry Andric 
4304eeddc0SDimitry Andric _LIBCPP_END_NAMESPACE_STD
4404eeddc0SDimitry Andric 
4506c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
4604eeddc0SDimitry Andric 
4704eeddc0SDimitry Andric #ifndef _LIBCPP_CXX03_LANG
4804eeddc0SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
4904eeddc0SDimitry Andric struct _FilesystemClock {
5004eeddc0SDimitry Andric #  if !defined(_LIBCPP_HAS_NO_INT128)
5104eeddc0SDimitry Andric   typedef __int128_t rep;
5204eeddc0SDimitry Andric   typedef nano period;
5304eeddc0SDimitry Andric #  else
5404eeddc0SDimitry Andric   typedef long long rep;
5504eeddc0SDimitry Andric   typedef nano period;
5604eeddc0SDimitry Andric #  endif
5704eeddc0SDimitry Andric 
5804eeddc0SDimitry Andric   typedef chrono::duration<rep, period> duration;
5904eeddc0SDimitry Andric   typedef chrono::time_point<_FilesystemClock> time_point;
6004eeddc0SDimitry Andric 
61*cb14a3feSDimitry Andric   _LIBCPP_EXPORTED_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
6204eeddc0SDimitry Andric 
6306c3fb27SDimitry Andric   _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI static time_point now() noexcept;
6404eeddc0SDimitry Andric 
6506c3fb27SDimitry Andric #  if _LIBCPP_STD_VER >= 20
6604eeddc0SDimitry Andric   template <class _Duration>
67*cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) {
6804eeddc0SDimitry Andric     return chrono::sys_time<_Duration>(__t.time_since_epoch());
6904eeddc0SDimitry Andric   }
7004eeddc0SDimitry Andric 
7104eeddc0SDimitry Andric   template <class _Duration>
72*cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) {
7304eeddc0SDimitry Andric     return chrono::file_time<_Duration>(__t.time_since_epoch());
7404eeddc0SDimitry Andric   }
7506c3fb27SDimitry Andric #  endif // _LIBCPP_STD_VER >= 20
7604eeddc0SDimitry Andric };
7704eeddc0SDimitry Andric _LIBCPP_END_NAMESPACE_FILESYSTEM
7804eeddc0SDimitry Andric #endif // !_LIBCPP_CXX03_LANG
7904eeddc0SDimitry Andric 
8004eeddc0SDimitry Andric #endif // _LIBCPP___CHRONO_FILE_CLOCK_H
81