Permalink
Browse files

Add ustime() from unstable into utils.c

  • Loading branch information...
1 parent 567d575 commit 32463852bea9d1ce35093a2673fc582b49373f7a @antirez committed Jun 8, 2011
Showing with 12 additions and 0 deletions.
  1. +11 −0 src/util.c
  2. +1 −0 src/util.h
View
@@ -327,6 +327,17 @@ int d2string(char *buf, size_t len, double value) {
return len;
}
+/* 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;
+}
+
#ifdef UTIL_TEST_MAIN
#include <assert.h>
View
@@ -8,5 +8,6 @@ int ll2string(char *s, size_t len, long long value);
int string2ll(char *s, size_t slen, long long *value);
int string2l(char *s, size_t slen, long *value);
int d2string(char *buf, size_t len, double value);
+long long ustime(void);
#endif

0 comments on commit 3246385

Please sign in to comment.