Browse Source

Add utility to get calendar ticks.

tags/1.0.0
Vsevolod Stakhov 8 years ago
parent
commit
d0863a174a
2 changed files with 22 additions and 0 deletions
  1. 16
    0
      src/libutil/util.c
  2. 6
    0
      src/libutil/util.h

+ 16
- 0
src/libutil/util.c View File

@@ -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)

+ 6
- 0
src/libutil/util.h View File

@@ -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

Loading…
Cancel
Save