summaryrefslogtreecommitdiff
path: root/src/common/compat_time.c
AgeCommit message (Collapse)Author
2017-03-15Run the copyright update script.Nick Mathewson
2016-12-21Withstand failures in CLOCK_MONOTONIC_COARSENick Mathewson
This came up on #21035, where somebody tried to build on a linux system with kernel headers including CLOCK_MONOTONIC_COARSE, then run on a kernel that didn't support it. I've adopted a belt-and-suspenders approach here: we detect failures at initialization time, and we also detect (loudly) failures later on. Fixes bug 21035; bugfix on 0.2.9.1-alpha when we started using monotonic time.
2016-07-29Keep make check-spaces happyAndrea Shepard
2016-07-26Fix an integer overflow related to monotonic time on windows.Nick Mathewson
To maintain precision, to get nanoseconds, we were multiplying our tick count by a billion, then dividing by ticks-per-second. But that apparently isn't such a great idea, since ticks-per-second is sometimes a billion on its own, so our intermediate result was giving us attoseconds. When you're counting in attoseconds, you can only fit about 9 seconds into an int64_t, which is not so great for our purposes. Instead, we now simplify the 1000000000/1000000000 fraction before we start messing with nanoseconds. This has potential to mess us up if some future MS version declares that performance counters will use 1,000,000,007 units per second, but let's burn that bridge when we come to it.
2016-07-26Remove windows debugging prints: it was an integer overflow hitting ftrapvNick Mathewson
2016-07-26fix identifier mistake :(Nick Mathewson
2016-07-26Redux^3: Temporarily add windows verbosity to track down jenkins failuresNick Mathewson
2016-07-26Redux^2: Temporarily add windows verbosity to track down jenkins failuresNick Mathewson
2016-07-26debugging: print ticks-per-second on windows. is it 0?Nick Mathewson
2016-07-26Temporarily add some windows verbosity to track down unit test failure on ↵Nick Mathewson
jenkins.
2016-07-26Try a little harder to work around mingw clock_gettime weirdnessNick Mathewson
2016-07-21ug no, the RIGHT fix.Nick Mathewson
2016-07-21Avoid infinite stack explosion in windows monotime.Nick Mathewson
[init calls get calls init calls get calls init.... ]
2016-07-21Once more, 32-bit fixes on monotime mockingNick Mathewson
2016-07-21loony mingwcross bug: insist we dont have clock_gettime.Nick Mathewson
2016-07-21fix monotime test mocking on 32-bit systemsNick Mathewson
2016-07-21Actually make monotonic time functions mockable.Nick Mathewson
This is different from making the functions mockable, since monotime_t is opaque and so providing mocks for the functions is really hard.
2016-07-21Revert "Make the monotonic{_coarse,}_get() functions mockable."Nick Mathewson
This reverts commit 2999f0b33fec8e91ba8e4680d3f9d03b09fe9501.
2016-07-21Make the monotonic{_coarse,}_get() functions mockable.Nick Mathewson
2016-07-19Make sure initialized_at is initialized before use.Nick Mathewson
2016-07-19Expose monotonic time ratchet functions for testing.Nick Mathewson
2016-07-19Basic portable monotonic timer implementationNick Mathewson
This code uses QueryPerformanceCounter() [**] on Windows, mach_absolute_time() on OSX, clock_gettime() where available, and gettimeofday() [*] elsewhere. Timer types are stored in an opaque OS-specific format; the only supported operation is to compute the difference between two timers. [*] As you know, gettimeofday() isn't monotonic, so we include a simple ratchet function to ensure that it only moves forward. [**] As you may not know, QueryPerformanceCounter() isn't actually always as monotonic as you might like it to be, so we ratchet that one too. We also include a "coarse monotonic timer" for cases where we don't actually need high-resolution time. This is GetTickCount{,64}() on Windows, clock_gettime(CLOCK_MONOTONIC_COARSE) on Linux, and falls back to regular monotonic time elsewhere.
2016-07-08Move our "what time is it now" compat functions into a new moduleNick Mathewson
I'm not moving our "format and parse the time" functions, since those have been pretty volatile over the last couple of years.