when calling clocks too early in DLL init, the vtables are not correctly
set up for some reason. Calls to init() from now() fail because the init
pointer in the vtable is NULL.
Real life example is mintty which runs into a minor problem at startup,
triggering a system_printf call. Strace is another problem, it's called
the first time prior to any class initialization.
Workaround is to make sure that no virtual methods are called in an
early stage. Make init() non-virtual and convert resolution() to a
virtual method instead. Add a special non-virtual
clk_monotonic_t::strace_usecs.
While at it:
- Inline internal-only methods.
- Drop the `inited' member. Convert period/ticks_per_sec toa union.
Initialize period/ticks_per_sec via InterlockeExchange64.
- Fix GetTickCount64 usage. No, it's not returning ticks but
milliseconds since boot (unbiased).
- Fix comment indentation.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Use whatever native unit the system provides for the resolution of
a timer to avoid rounding problems
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- Drop hires_[nm]s clocks, rename hires.h to clock.h.
- Implement clk_t class as an extensible clock class in new file clock.cc.
- Introduce get_clock(clock_id) returning a pointer to the clk_t instance
for clock_id. Provide the following methods along the lines of the former
hires classes:
void clk_t::nsecs (struct timespec *);
ULONGLONG clk_t::nsecs ();
LONGLONG clk_t::usecs ();
LONGLONG clk_t::msecs ();
void clk_t::resolution (struct timespec *);
- Add CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE
and CLOCK_BOOTTIME clocks.
- Allow clock_nanosleep, pthread_condattr_setclock and timer_create to use
all new clocks (both clocks should be usable with a small tweak, though).
- Bump DLL major version to 2.12.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>