Interegrated changes to Timer from Neil Salter to fix compilation problems which had been introduced by doing #include's within the osg namespace.

This commit is contained in:
Robert Osfield 2001-09-30 20:41:20 +00:00
parent 777e4ab9f1
commit ef3217cfde

View File

@ -47,10 +47,14 @@ class SG_EXPORT Timer {
}; };
};
#ifdef WIN32 #ifdef WIN32
#include <time.h> #include <time.h>
#pragma optimize("",off) #pragma optimize("",off)
namespace osg{
inline Timer_t Timer::tick( void ) inline Timer_t Timer::tick( void )
{ {
if (_useStandardClock) return clock(); if (_useStandardClock) return clock();
@ -72,6 +76,8 @@ class SG_EXPORT Timer {
*((unsigned int*)&ts+1) = HighPart; *((unsigned int*)&ts+1) = HighPart;
return ts; return ts;
} }
};
#pragma optimize("",on) #pragma optimize("",on)
#elif defined(__linux) || defined(__FreeBSD__) #elif defined(__linux) || defined(__FreeBSD__)
@ -79,6 +85,9 @@ class SG_EXPORT Timer {
#include <sys/time.h> #include <sys/time.h>
#define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)) #define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x))
namespace osg{
inline Timer_t Timer::tick() inline Timer_t Timer::tick()
{ {
if (_useStandardClock) if (_useStandardClock)
@ -92,10 +101,15 @@ class SG_EXPORT Timer {
Timer_t x;CLK(x);return x; Timer_t x;CLK(x);return x;
} }
} }
};
#elif defined(__sgi) #elif defined(__sgi)
#include <sys/time.h> #include <sys/time.h>
namespace osg{
inline Timer_t Timer::tick() inline Timer_t Timer::tick()
{ {
if (_useStandardClock) if (_useStandardClock)
@ -109,23 +123,30 @@ class SG_EXPORT Timer {
return *_sgiClockAddress; return *_sgiClockAddress;
} }
} }
};
#elif defined(unix) #elif defined(unix)
#include <sys/time.h> #include <sys/time.h>
namespace osg{
inline Timer_t Timer::tick() inline Timer_t Timer::tick()
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
} }
};
#else #else
// no choice, always use std::clock() // no choice, always use std::clock()
namespace osg{
inline Timer_t Timer::tick( void ) { return std::clock(); } inline Timer_t Timer::tick( void ) { return std::clock(); }
#endif
}; };
#endif
#endif #endif