mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
IO: Add current_time_now() function for immediate timestamp
Add a current_time_now() function which gets an immediate monotonic timestamp instead of using the cached value from the event loop. This is useful for callers that need precise times, such as the Babel RTT measurement code. Minor changes by committer.
This commit is contained in:
parent
d7163f6427
commit
7176f62788
@ -46,6 +46,9 @@ extern struct timeloop main_timeloop;
|
|||||||
btime current_time(void);
|
btime current_time(void);
|
||||||
btime current_real_time(void);
|
btime current_real_time(void);
|
||||||
|
|
||||||
|
/* In sysdep code */
|
||||||
|
btime current_time_now(void);
|
||||||
|
|
||||||
//#define now (current_time() TO_S)
|
//#define now (current_time() TO_S)
|
||||||
//#define now_real (current_real_time() TO_S)
|
//#define now_real (current_real_time() TO_S)
|
||||||
extern btime boot_time;
|
extern btime boot_time;
|
||||||
|
@ -171,6 +171,19 @@ times_update_real_time(struct timeloop *loop)
|
|||||||
loop->real_time = ts.tv_sec S + ts.tv_nsec NS;
|
loop->real_time = ts.tv_sec S + ts.tv_nsec NS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btime
|
||||||
|
current_time_now(void)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
if (rv < 0)
|
||||||
|
die("clock_gettime: %m");
|
||||||
|
|
||||||
|
return ts.tv_sec S + ts.tv_nsec NS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DOC: Sockets
|
* DOC: Sockets
|
||||||
|
Loading…
Reference in New Issue
Block a user