00001 #include <time.h>
00002 #include <sys/time.h>
00003 #include <stdint.h>
00004 #include "helpers.h"
00005
00006 double gettime()
00007 {
00008 #if POSIX_TIMERS > 0
00009 struct timespec curtime;
00010 clock_gettime(CLOCK_REALTIME, &curtime);
00011 return (uint64_t)(curtime.tv_sec) + (uint64_t)(curtime.tv_nsec) * 1e-9;
00012 #else
00013 struct timeval timeofday;
00014 gettimeofday(&timeofday,NULL);
00015 return (uint64_t)(timeofday.tv_sec) + (uint64_t)(timeofday.tv_usec) * 1e-6;
00016 #endif
00017 }