commit | 04be460be93cb983fde30a7c825a925971d0548c | [log] [tgz] |
---|---|---|
author | Martin Storsjö <martin@martin.st> | Thu Dec 17 15:40:06 2020 +0200 |
committer | Copybara-Service <copybara-worker@google.com> | Wed Jan 13 14:37:37 2021 -0800 |
tree | bf7eb8435598a5885f5ba63f874804e5fbe94895 | |
parent | 80bf5f7e7d8760f23d9d12ec7a3953b0386184ef [diff] |
[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 GitOrigin-RevId: 02f1d28ed6b8f33445dae3beed8b6cc8dada4312