003 File Manager
Current Path:
/usr/src/contrib/llvm-project/libcxx/src
usr
/
src
/
contrib
/
llvm-project
/
libcxx
/
src
/
📁
..
📄
algorithm.cpp
(3.73 KB)
📄
any.cpp
(933 B)
📄
atomic.cpp
(7.67 KB)
📄
barrier.cpp
(3.77 KB)
📄
bind.cpp
(715 B)
📄
charconv.cpp
(4.51 KB)
📄
chrono.cpp
(4.94 KB)
📄
condition_variable.cpp
(2.73 KB)
📄
condition_variable_destructor.cpp
(1.26 KB)
📄
debug.cpp
(13.37 KB)
📄
exception.cpp
(1.25 KB)
📁
experimental
📁
filesystem
📄
functional.cpp
(656 B)
📄
future.cpp
(6.21 KB)
📄
hash.cpp
(13.04 KB)
📁
include
📄
ios.cpp
(12.62 KB)
📄
iostream.cpp
(5.66 KB)
📄
locale.cpp
(189.52 KB)
📄
memory.cpp
(6.15 KB)
📄
mutex.cpp
(5.77 KB)
📄
mutex_destructor.cpp
(1.44 KB)
📄
new.cpp
(5.98 KB)
📄
optional.cpp
(1.16 KB)
📄
random.cpp
(3.98 KB)
📄
random_shuffle.cpp
(1.26 KB)
📄
regex.cpp
(8.22 KB)
📄
shared_mutex.cpp
(2.86 KB)
📄
stdexcept.cpp
(592 B)
📄
string.cpp
(11.54 KB)
📄
strstream.cpp
(8.46 KB)
📁
support
📄
system_error.cpp
(6.88 KB)
📄
thread.cpp
(5.42 KB)
📄
typeinfo.cpp
(1.79 KB)
📄
utility.cpp
(497 B)
📄
valarray.cpp
(1.67 KB)
📄
variant.cpp
(517 B)
📄
vector.cpp
(529 B)
Editing: chrono.cpp
//===------------------------- chrono.cpp ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "chrono" #include "cerrno" // errno #include "system_error" // __throw_system_error #include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW} #include "include/apple_availability.h" #if __has_include(<unistd.h>) #include <unistd.h> #endif #if !defined(__APPLE__) && _POSIX_TIMERS > 0 #define _LIBCPP_USE_CLOCK_GETTIME #endif #if defined(_LIBCPP_WIN32API) # define WIN32_LEAN_AND_MEAN # define VC_EXTRA_LEAN # include <windows.h> # if _WIN32_WINNT >= _WIN32_WINNT_WIN8 # include <winapifamily.h> # endif #else # if !defined(CLOCK_REALTIME) # include <sys/time.h> // for gettimeofday and timeval # endif // !defined(CLOCK_REALTIME) #endif // defined(_LIBCPP_WIN32API) #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) # pragma comment(lib, "rt") #endif _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { // system_clock const bool system_clock::is_steady; system_clock::time_point system_clock::now() _NOEXCEPT { #if defined(_LIBCPP_WIN32API) // FILETIME is in 100ns units using filetime_duration = _VSTD::chrono::duration<__int64, _VSTD::ratio_multiply<_VSTD::ratio<100, 1>, nanoseconds::period>>; // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970. static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600}; FILETIME ft; #if _WIN32_WINNT >= _WIN32_WINNT_WIN8 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) GetSystemTimePreciseAsFileTime(&ft); #else GetSystemTimeAsFileTime(&ft); #endif #else GetSystemTimeAsFileTime(&ft); #endif filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) | static_cast<__int64>(ft.dwLowDateTime)}; return time_point(duration_cast<duration>(d - nt_to_unix_epoch)); #else #if defined(CLOCK_REALTIME) struct timespec tp; if (0 != clock_gettime(CLOCK_REALTIME, &tp)) __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); #else timeval tv; gettimeofday(&tv, 0); return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); #endif // CLOCK_REALTIME #endif } time_t system_clock::to_time_t(const time_point& t) _NOEXCEPT { return time_t(duration_cast<seconds>(t.time_since_epoch()).count()); } system_clock::time_point system_clock::from_time_t(time_t t) _NOEXCEPT { return system_clock::time_point(seconds(t)); } #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK // steady_clock // // Warning: If this is not truly steady, then it is non-conforming. It is // better for it to not exist and have the rest of libc++ use system_clock // instead. const bool steady_clock::is_steady; #if defined(__APPLE__) #if !defined(CLOCK_MONOTONIC_RAW) # error "Building libc++ on Apple platforms requires CLOCK_MONOTONIC_RAW" #endif // On Apple platforms, only CLOCK_UPTIME_RAW, CLOCK_MONOTONIC_RAW or // mach_absolute_time are able to time functions in the nanosecond range. // Furthermore, only CLOCK_MONOTONIC_RAW is truly monotonic, because it // also counts cycles when the system is asleep. Thus, it is the only // acceptable implementation of steady_clock. steady_clock::time_point steady_clock::now() _NOEXCEPT { struct timespec tp; if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp)) __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed"); return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); } #elif defined(_LIBCPP_WIN32API) // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says: // If the function fails, the return value is zero. <snip> // On systems that run Windows XP or later, the function will always succeed // and will thus never return zero. static LARGE_INTEGER __QueryPerformanceFrequency() { LARGE_INTEGER val; (void) QueryPerformanceFrequency(&val); return val; } steady_clock::time_point steady_clock::now() _NOEXCEPT { static const LARGE_INTEGER freq = __QueryPerformanceFrequency(); LARGE_INTEGER counter; (void) QueryPerformanceCounter(&counter); return time_point(duration(counter.QuadPart * nano::den / freq.QuadPart)); } #elif defined(CLOCK_MONOTONIC) steady_clock::time_point steady_clock::now() _NOEXCEPT { struct timespec tp; if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed"); return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); } #else # error "Monotonic clock not implemented" #endif #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK } _LIBCPP_END_NAMESPACE_STD
Upload File
Create Folder