diff options
Diffstat (limited to 'globals.c')
-rw-r--r-- | globals.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include "globals.h" #include <time.h> +#include <sys/time.h> GlobalStruct globals = { @@ -19,3 +20,16 @@ long sec_timer (void) { return (long)time(NULL); } + + +unsigned long long ms_timer (void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + + unsigned long long millisecondsSinceEpoch = + (unsigned long long)(tv.tv_sec) * 1000 + + (unsigned long long)(tv.tv_usec) / 1000; + + return millisecondsSinceEpoch; +} |