mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-12 16:41:59 +00:00
miracle: add now() helper
This returns the current time in usec since EPOCH depending on the clock-time. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
parent
3db84c3822
commit
77aae60c52
1 changed files with 12 additions and 0 deletions
|
@ -31,7 +31,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <systemd/sd-bus.h>
|
||||
#include <time.h>
|
||||
#include "shl_log.h"
|
||||
#include "shl_macro.h"
|
||||
|
||||
|
@ -116,4 +118,14 @@ static inline int bus_message_read_basic_variant(sd_bus_message *m,
|
|||
_l; \
|
||||
})
|
||||
|
||||
static inline int64_t now(clockid_t clock_id)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(clock_id, &ts);
|
||||
|
||||
return (int64_t)ts.tv_sec * 1000000LL +
|
||||
(int64_t)ts.tv_nsec / 1000LL;
|
||||
}
|
||||
|
||||
#endif /* MIRACLE_H */
|
||||
|
|
Loading…
Reference in a new issue