diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 1e5d5a928..1e3a488fa 100644 --- a/src/util.c +++ b/src/util.c @@ -1,6 +1,7 @@ #include "redis.h" #include <ctype.h> #include <limits.h> +#include <sys/time.h> /* Glob-style pattern matching. */ int stringmatchlen(const char *pattern, int patternLen, @@ -301,3 +302,14 @@ int string2ll(char *s, size_t slen, long long *value) { } return 1; } + +/* Return the UNIX time in microseconds */ +long long ustime(void) { + struct timeval tv; + long long ust; + + gettimeofday(&tv, NULL); + ust = ((long long)tv.tv_sec)*1000000; + ust += tv.tv_usec; + return ust; +} |