timer.c revision e0e0c19eefceaf5d4ec40f9466b58a771f50e799
#ifndef WINDOWS
#include <stddef.h>
#include <fcntl.h>
#endif
#include <unistd.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "cr_timer.h"
#include "cr_mem.h"
#include "cr_error.h"
static double crTimerGetTime( CRTimer *t )
{
if (t->iotimer_addr64) {
volatile iotimer64_t counter_value;
counter_value = *(t->iotimer_addr64);
}
else {
volatile iotimer32_t counter_value;
counter_value = *(t->iotimer_addr32);
}
#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1)
#else
#endif
}
CRTimer *crTimerNewTimer( void )
{
crError( "Sorry, this SGI doesn't support timers." );
}
if (counterSize == 64) {
t->iotimer_addr64 =
t->unmapLocation = (void *)t->iotimer_addr64;
}
else if (counterSize == 32) {
MAP_PRIVATE, t->fd,
t->unmapLocation = (void *)t->iotimer_addr32;
}
else {
crError( "Fatal timer init error" );
}
#endif
t->running = 0;
return t;
}
void crDestroyTimer( CRTimer *t )
{
#endif
crFree( t );
}
void crStartTimer( CRTimer *t )
{
t->running = 1;
t->time0 = crTimerGetTime( t );
}
void crStopTimer( CRTimer *t )
{
t->running = 0;
}
void crResetTimer( CRTimer *t )
{
t->running = 0;
t->elapsed = 0;
}
double crTimerTime( CRTimer *t )
{
if (t->running) {
crStopTimer( t );
crStartTimer( t );
}
return t->elapsed;
}