mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-08 06:00:54 +00:00
clock: handle uninitialized clock gracefully
If we haven't discovered the proper clock, just default to monotonic.
This commit is contained in:
@ -34,8 +34,11 @@ static inline SpTimeStamp
|
|||||||
sp_clock_get_current_time (void)
|
sp_clock_get_current_time (void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
SpClock clock = sp_clock;
|
||||||
|
|
||||||
clock_gettime (sp_clock, &ts);
|
if G_UNLIKELY (clock == -1)
|
||||||
|
clock = CLOCK_MONOTONIC;
|
||||||
|
clock_gettime (clock, &ts);
|
||||||
|
|
||||||
return (ts.tv_sec * G_GINT64_CONSTANT (1000000000)) + ts.tv_nsec;
|
return (ts.tv_sec * G_GINT64_CONSTANT (1000000000)) + ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user