clray

view src/timer.cc @ 62:d9520da6b801

minor readme fix
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Dec 2015 10:31:58 +0200
parents
children
line source
1 #include "timer.h"
3 #if defined(unix) || defined(__unix__) || defined(__APPLE__)
4 #include <unistd.h>
5 #include <sys/time.h>
7 long get_msec()
8 {
9 static struct timeval tv0;
10 struct timeval tv;
12 gettimeofday(&tv, 0);
14 if(tv0.tv_sec == 0 && tv0.tv_usec == 0) {
15 tv0 = tv;
16 return 0;
17 }
18 return (tv.tv_sec - tv0.tv_sec) * 1000L + (tv.tv_usec - tv0.tv_usec) / 1000L;
19 }
21 #elif defined(WIN32) || defined(__WIN32__)
22 #include <windows.h>
24 #pragma comment(lib, "winmm.lib")
26 long get_msec()
27 {
28 return timeGetTime();
29 }
30 #endif