diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-15 13:38:30 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-15 13:38:30 +0100 |
commit | d0863a174ad1a9d91f3123164bcccc9621f427ed (patch) | |
tree | 4a240533927c1437559b469d471784ff8498cf97 /src/libutil/util.c | |
parent | 7330952d4fb455c073376745776ac771e6882c0a (diff) | |
download | rspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.tar.gz rspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.zip |
Add utility to get calendar ticks.
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r-- | src/libutil/util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index b537643ca..983accf62 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -1856,6 +1856,22 @@ rspamd_get_virtual_ticks (void) return res; } +gdouble +rspamd_get_calendar_ticks (void) +{ + gdouble res; + struct timeval tv; + + if (gettimeofday (&tv, NULL) == 0) { + res = (gdouble)tv.tv_sec + tv.tv_usec / 1e6f; + } + else { + res = time (NULL); + } + + return res; +} + /* Required for tweetnacl */ void randombytes (guchar *buf, guint64 len) |