]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add i_gettimeofday()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 24 Jan 2020 21:27:09 +0000 (23:27 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 6 Feb 2020 06:46:01 +0000 (06:46 +0000)
src/lib/time-util.c
src/lib/time-util.h

index 31eaf71b2e073be4a6a53e720d581a5aeaa28ff0..32688c1cd48ea83c8c6fe71771d54ba5e6cdc26c 100644 (file)
@@ -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)
index 33ddbd9c46349477454ac72b1a4aa71f12465b33..139ebf65069f026c6b6ec4508f183a2e2d185053 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <sys/time.h> /* for struct timeval */
 
+/* Same as gettimeofday(), but call i_fatal() if the call fails. */
+void i_gettimeofday(struct timeval *tv_r);
+
 /* Returns -1 if tv1<tv2, 1 if tv1>tv2, 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 */