eqemu
diff src/timer.cc @ 2:48dce4ee4850
the fake device is working
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Jul 2014 14:37:51 +0300 |
parents | |
children | e9ab4861536d |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/timer.cc Tue Jul 15 14:37:51 2014 +0300 1.3 @@ -0,0 +1,15 @@ 1.4 +#include <unistd.h> 1.5 +#include <sys/time.h> 1.6 + 1.7 +unsigned long get_msec() 1.8 +{ 1.9 + static struct timeval tv0; 1.10 + struct timeval tv; 1.11 + 1.12 + gettimeofday(&tv, 0); 1.13 + if(tv0.tv_sec == 0 && tv0.tv_usec == 0) { 1.14 + tv0 = tv; 1.15 + return 0; 1.16 + } 1.17 + return (tv.tv_sec - tv0.tv_sec) * 1000 + (tv.tv_usec - tv0.tv_usec) / 1000; 1.18 +}