From: Timo Sirainen Date: Fri, 24 Jan 2020 21:27:09 +0000 (+0200) Subject: lib: Add i_gettimeofday() X-Git-Tag: 2.3.10~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ea9109ecc3ec544522ac2d639c513efe229bd99;p=thirdparty%2Fdovecot%2Fcore.git lib: Add i_gettimeofday() --- diff --git a/src/lib/time-util.c b/src/lib/time-util.c index 31eaf71b2e..32688c1cd4 100644 --- a/src/lib/time-util.c +++ b/src/lib/time-util.c @@ -7,6 +7,12 @@ #define STRFTIME_MAX_BUFSIZE (1024*64) +void i_gettimeofday(struct timeval *tv_r) +{ + if (gettimeofday(tv_r, NULL) < 0) + i_fatal("gettimeofday() failed: %m"); +} + int timeval_cmp(const struct timeval *tv1, const struct timeval *tv2) { if (tv1->tv_sec < tv2->tv_sec) diff --git a/src/lib/time-util.h b/src/lib/time-util.h index 33ddbd9c46..139ebf6506 100644 --- a/src/lib/time-util.h +++ b/src/lib/time-util.h @@ -3,6 +3,9 @@ #include /* for struct timeval */ +/* Same as gettimeofday(), but call i_fatal() if the call fails. */ +void i_gettimeofday(struct timeval *tv_r); + /* Returns -1 if tv1tv2, 0 if they're equal. */ int timeval_cmp(const struct timeval *tv1, const struct timeval *tv2); /* Same as timeval_cmp, but tv->usecs must differ by at least usec_margin */