#include "jd_time.h" unsigned long Millitimer_Adjust=0; #ifdef WIN32 /* windows version */ #include unsigned long Get_Milliseconds() { struct _timeb timebuffer; _ftime( &timebuffer ); unsigned long seconds = timebuffer.time*1000 + timebuffer.millitm + Millitimer_Adjust; //printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] ); return(seconds); } #else /* unix version*/ #include /* 10 millisecond resolution on most machines according to man pages. I seem to be getting 1 millisecond accuracy though.. See timers(5) and getitimer(2) for info on max rate */ unsigned long Get_Milliseconds(void) { struct timeval mytime; unsigned long time; static unsigned long base=0; gettimeofday(&mytime); /* if (base==0) base=mytime.tv_sec; */ time=(mytime.tv_sec-base)*1000 + (mytime.tv_usec/1000) + Millitimer_Adjust; return time; } #endif