timer_posix.cpp

Go to the documentation of this file.
00001 #include <time.h>
00002 #include <sys/time.h>
00003 #include "timer.h"
00004 #include "types.h"
00005 
00006 
00007 namespace audiere {
00008 
00009   u64 GetNow() {
00010 
00011 #if HAVE_CLOCK_GETTIME
00012     // use the POSIX realtime clock to get the current time
00013     struct timespec tp;
00014     int result = clock_gettime(CLOCK_REALTIME, &tp);
00015     if (result == 0) {
00016       return u64(tp.tv_sec) * 1000000 + u64(tp.tv_nsec) / 1000;
00017     }
00018 #endif
00019 
00020     // can't use realtime clock!  Try to use gettimeofday
00021     struct timeval tv;
00022     gettimeofday(&tv, 0);
00023     return u64(tv.tv_sec) * 1000000 + tv.tv_usec;
00024   }
00025 
00026 }

Generated on Mon Feb 13 23:07:47 2006 for audiere by  doxygen 1.4.6