# HG changeset patch # User John Tsiombikas # Date 1282625224 -3600 # Node ID 931d13b72f838c50738d66a204d338a1dfede35a # Parent 4cf4919c381209313293d3c663c0d57c530cdd1e forgot to add the timers diff -r 4cf4919c3812 -r 931d13b72f83 src/timer.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/timer.cc Tue Aug 24 05:47:04 2010 +0100 @@ -0,0 +1,30 @@ +#include "timer.h" + +#if defined(unix) || defined(__unix__) || defined(__APPLE__) +#include +#include + +long get_msec() +{ + static struct timeval tv0; + struct timeval tv; + + gettimeofday(&tv, 0); + + if(tv0.tv_sec == 0 && tv0.tv_usec == 0) { + tv0 = tv; + return 0; + } + return (tv.tv_sec - tv0.tv_sec) * 1000L + (tv.tv_usec - tv0.tv_usec) / 1000L; +} + +#elif defined(WIN32) || defined(__WIN32__) +#include + +#pragma comment(lib, "winmm.lib") + +long get_msec() +{ + return timeGetTime(); +} +#endif diff -r 4cf4919c3812 -r 931d13b72f83 src/timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/timer.h Tue Aug 24 05:47:04 2010 +0100 @@ -0,0 +1,6 @@ +#ifndef TIMER_H_ +#define TIMER_H_ + +long get_msec(); + +#endif /* TIMER_H_ */