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 | |
parent | 7330952d4fb455c073376745776ac771e6882c0a (diff) | |
download | rspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.tar.gz rspamd-d0863a174ad1a9d91f3123164bcccc9621f427ed.zip |
Add utility to get calendar ticks.
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/util.c | 16 | ||||
-rw-r--r-- | src/libutil/util.h | 6 |
2 files changed, 22 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) diff --git a/src/libutil/util.h b/src/libutil/util.h index 536caed2c..b0a165004 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -357,6 +357,12 @@ gdouble rspamd_get_ticks (void); */ gdouble rspamd_get_virtual_ticks (void); + +/** + * Return the real timestamp as unixtime + */ +gdouble rspamd_get_calendar_ticks (void); + /** * Special utility to help array freeing in rspamd_mempool * @param p |