llvm-project/libcxx/src
Martin Storsjö 02f1d28ed6 [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()
As freq.QuadValue can be in the range of 10000000 to 19200000,
the multiplication before division makes the calculation overflow
and wrap to negative values every 16-30 minutes.

Instead count the whole seconds separately before adding the
scaled fractional seconds.

Add a testcase for steady_clock to check that the values returned for
now() compare as bigger than the zero time origin; this
corresponds to a testcase in Qt [1] [2] (that failed spuriously
due to this).

[1] https://bugreports.qt.io/browse/QTBUG-89539
[2] https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp?id=f8de5e54022b8b7471131b7ad55c83b69b2684c0#n569

Differential Revision: https://reviews.llvm.org/D93456
2021-01-12 23:56:03 +02:00
..
experimental Guard init_priority attribute within libc++ 2020-11-20 15:53:26 -05:00
filesystem [libcxx] Handle backslash as path separator on windows 2021-01-07 10:02:47 +02:00
include [libcxx] Port to NuttX (https://nuttx.apache.org) RTOS 2020-11-18 16:20:56 -05:00
support [libc++] Remove emscripten handling from exception_fallback.ipp 2020-11-09 16:09:54 -08:00
CMakeLists.txt [runtimes] Avoid overwriting the rpath unconditionally 2020-11-09 16:56:03 -05:00
algorithm.cpp [libc++] Split dylib instantiations for deprecated std::random_shuffle into a separate source file 2020-06-30 13:50:17 -04:00
any.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
atomic.cpp [libc++] NFC: Remove unused <iostream> include in atomic.cpp 2020-10-05 16:41:25 -04:00
barrier.cpp [libc++] Build the dylib with C++17 to allow aligned new/delete 2020-07-22 14:47:29 -04:00
bind.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
charconv.cpp [libc++] Mark __u64toa and __u32toa as noexcept 2020-05-22 16:11:44 -04:00
chrono.cpp [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now() 2021-01-12 23:56:03 +02:00
condition_variable.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
condition_variable_destructor.cpp Make ~mutex and ~condition_variable trivial on Windows. 2019-07-07 17:24:03 +00:00
debug.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
exception.cpp [libc++] Remove redundant conditionals for Apple platforms 2019-04-23 14:05:04 +00:00
functional.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
future.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
hash.cpp [libc++] Avoid UB in the no-exceptions mode in a few places 2019-02-12 16:06:02 +00:00
ios.cpp [libc++] Split off iostreams explicit instantiations into its own source file 2020-11-02 10:36:34 -05:00
ios.instantiations.cpp [libc++] Instantiate additional <iostream> members in the dylib 2020-11-12 13:52:47 -05:00
iostream.cpp Guard init_priority attribute within libc++ 2020-11-20 15:53:26 -05:00
locale.cpp [libc++] [P0482] [C++20] Implement missing bits for codecvt and codecvt_byname. 2020-12-02 09:01:58 +01:00
memory.cpp [libc++] Make __shared_weak_count vtable consistent across all build configurations 2020-10-20 08:19:43 -04:00
mutex.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
mutex_destructor.cpp [libc++][NFC] Remove excess trailing newlines from most files 2019-10-23 08:08:57 -07:00
new.cpp [libc++/abi] Re-remove unnecessary null pointer checks from operator delete 2021-01-08 17:03:50 -05:00
optional.cpp [libc++] Rework the whole availability markup implementation 2020-11-05 12:28:52 -05:00
random.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
random_shuffle.cpp [libc++] Split dylib instantiations for deprecated std::random_shuffle into a separate source file 2020-06-30 13:50:17 -04:00
regex.cpp [libc++] Validate the entire regex is consumed 2019-11-09 17:01:37 +01:00
shared_mutex.cpp [libcxx{,abi}] Emit deplibs only when detected by CMake 2019-12-02 22:19:20 +01:00
stdexcept.cpp Fix ABI compatibility of `<stdexcept>` with VCRuntime. 2019-03-06 20:31:57 +00:00
string.cpp Add flag _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATIONS for basic_string ABI 2020-03-02 10:26:37 -05:00
strstream.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
system_error.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
thread.cpp [libc++] Remove sysctl-based implementation of thread::hardware_concurrency() 2020-11-26 12:00:59 -05:00
typeinfo.cpp [libc++] Remove redundant conditionals for Apple platforms 2019-04-23 14:05:04 +00:00
utility.cpp [libc++] Take 2: Implement LWG 2510 2019-09-26 14:51:10 +00:00
valarray.cpp [libc++] Always build with -fvisibility=hidden 2019-08-13 15:02:53 +00:00
variant.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
vector.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00