vrseasons

diff src/timer.c @ 0:393ef1143c9c

VR seasons
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 07 Apr 2015 11:16:56 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/timer.c	Tue Apr 07 11:16:56 2015 +0300
     1.3 @@ -0,0 +1,23 @@
     1.4 +#include "timer.h"
     1.5 +
     1.6 +#if defined(__unix__) || defined(__APPLE__)
     1.7 +#include <time.h>
     1.8 +
     1.9 +unsigned long get_msec(void)
    1.10 +{
    1.11 +	struct timespec ts;
    1.12 +	if(clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
    1.13 +		clock_gettime(CLOCK_REALTIME, &ts);
    1.14 +	}
    1.15 +	return ts.tv_sec * 1000ul + ts.tv_nsec / 1000000ul;
    1.16 +}
    1.17 +
    1.18 +#elif defined(WIN32)
    1.19 +#include <windows.h>
    1.20 +
    1.21 +unsigned long get_msec(void)
    1.22 +{
    1.23 +	return timeGetTime();
    1.24 +}
    1.25 +
    1.26 +#endif