From f7557c6ee7055409b1dab3541480552702575343 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 14 Jan 2020 15:30:55 +0100 Subject: [PATCH] pam: Add monotonic clock helper --- pam/pam_fprintd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pam/pam_fprintd.c b/pam/pam_fprintd.c index ec40da7..0fcfdb9 100644 --- a/pam/pam_fprintd.c +++ b/pam/pam_fprintd.c @@ -23,6 +23,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -61,6 +62,17 @@ static gboolean debug = FALSE; static guint max_tries = DEFAULT_MAX_TRIES; static guint timeout = DEFAULT_TIMEOUT; +#define USEC_PER_SEC ((uint64_t) 1000000ULL) +#define NSEC_PER_USEC ((uint64_t) 1000ULL) + +static uint64_t +now (void) +{ + struct timespec ts; + clock_gettime (CLOCK_MONOTONIC, &ts); + return (uint64_t) ts.tv_sec * USEC_PER_SEC + (uint64_t) ts.tv_nsec / NSEC_PER_USEC; +} + static gboolean send_info_msg(pam_handle_t *pamh, const char *msg) { const struct pam_message mymsg = {