summaryrefslogtreecommitdiff
path: root/src/common/compat_time.c
AgeCommit message (Collapse)Author
2018-06-28Extract time functionality into lib/wallclock and lib/timeNick Mathewson
2018-06-22Automated fixup of include paths after torlog.h movement.Nick Mathewson
2018-06-22Extract our code for answering "what time is it right now".Nick Mathewson
The other time stuff is higher-level
2018-06-22Expunge container.hNick Mathewson
2018-06-22Rectify include paths after container split (automatic)Nick Mathewson
2018-06-21Rectify include paths (automated)Nick Mathewson
2018-06-20Move horrible-emergency handling into torerr.[ch]Nick Mathewson
Previously we had code like this for bad things happening from signal handlers, but it makes sense to use the same logic to handle cases when something is happening at a level too low for log.c to be involved. My raw_assert*() stuff now uses this code.
2018-06-20Use raw_assert in tor_gettimeofdayNick Mathewson
We don't want to actually be calling logs when gettimeofday() fails, since we need gettimeofday() to log.
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-05-02Bug 26000: Fix missing ";"Georg Koppen
2018-04-26Add a function to compute millisecond time difference quickly.Nick Mathewson
Our main function, though accurate on all platforms, can be very slow on 32-bit hosts. This one is faster on all 32-bit hosts, and accurate everywhere except apple, where it will typically be off by 1%. But since 32-bit apple is a relic anyway, I think we should be fine.
2018-04-16Make tor_gettimeofday() mockableNeel Chauhan
2018-04-13Expose a function that computes stamp units from msec.Nick Mathewson
(It turns out we can't just expose STAMP_TICKS_PER_SECOND, since Apple doesn't have that.)
2018-02-07Fix spelling mistakes corresponding to ticket #23650Deepesh Pathak
2017-12-20type error fix for monotime_coarse_add_msec on windowsNick Mathewson
2017-12-13Add a function to add msec to a monotime.Nick Mathewson
We'll use this for the channel padding logic.
2017-12-13Add monotime functions for clearing monotonic timesNick Mathewson
We need this to replace some of our "msec" users with monotime users.
2017-12-08Use mach_approximate_time() for coarse time where available.Nick Mathewson
This lets us have a coarse-time implementation with reasonable performance characteristics on OSX and iOS. Implements 24427.
2017-12-07add a missing windows underscoreNick Mathewson
2017-12-06Fix a compiler warningNick Mathewson
2017-12-06Merge remote-tracking branch 'public/monotime_coarse_stamps'Nick Mathewson
2017-11-27Add a new notion of "stamps" to be a fast 32-bit monotonic timestampNick Mathewson
The goal here is to replace our use of msec-based timestamps with something less precise, but easier to calculate. We're doing this because calculating lots of msec-based timestamps requires lots of 64/32 division operations, which can be inefficient on 32-bit platforms. We make sure that these stamps can be calculated using only the coarse monotonic timer and 32-bit bitwise operations.
2017-10-19Comment-only change: annotate exit() calls.Nick Mathewson
Sometimes when we call exit(), it's because the process is completely hopeless: openssl has a broken AES-CTR implementation, or the clock is in the 1960s, or something like that. But sometimes, we should return cleanly from tor_main() instead, so that embedders can keep embedding us and start another Tor process. I've gone through all the exit() and _exit() calls to annotate them with "exit ok" or "XXXX bad exit" -- the next step will be to fix the bad exit()s. First step towards 23848.
2017-09-15Run our #else/#endif annotator on our source code.Nick Mathewson
2017-08-24Apply test-operator-cleanup to src/common too.Nick Mathewson
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.