clray

view src/timer.cc @ 51:9c0867942612

changed the binary target to clray
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 02 Sep 2010 01:41:51 +0100
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