eqemu

annotate src/timer.cc @ 7:e9ab4861536d

added glow
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 18 Jul 2014 04:24:53 +0300
parents 48dce4ee4850
children 2656099aff12
rev   line source
nuclear@2 1 #include <unistd.h>
nuclear@2 2 #include <sys/time.h>
nuclear@2 3
nuclear@2 4 unsigned long get_msec()
nuclear@2 5 {
nuclear@2 6 static struct timeval tv0;
nuclear@2 7 struct timeval tv;
nuclear@2 8
nuclear@2 9 gettimeofday(&tv, 0);
nuclear@2 10 if(tv0.tv_sec == 0 && tv0.tv_usec == 0) {
nuclear@2 11 tv0 = tv;
nuclear@2 12 return 0;
nuclear@2 13 }
nuclear@2 14 return (tv.tv_sec - tv0.tv_sec) * 1000 + (tv.tv_usec - tv0.tv_usec) / 1000;
nuclear@2 15 }
nuclear@7 16
nuclear@7 17 void wait_for(unsigned long msec)
nuclear@7 18 {
nuclear@7 19 usleep(msec * 1000);
nuclear@7 20 }