From Eric Wing, clean ups for OSX support.
This commit is contained in:
@@ -56,14 +56,7 @@ class SG_EXPORT Timer {
|
||||
|
||||
static const Timer* instance();
|
||||
|
||||
|
||||
#if defined __APPLE__ || defined macintosh
|
||||
// PJA MAC OSX - inline Tick() pollutes namespace so badly
|
||||
// we cant compile, due to Carbon.h ...
|
||||
Timer_t tick() const;
|
||||
#else
|
||||
inline Timer_t tick() const;
|
||||
#endif
|
||||
|
||||
inline double delta_s( Timer_t t1, Timer_t t2 ) const { return (double)(t2 - t1)*_secsPerTick; }
|
||||
inline double delta_m( Timer_t t1, Timer_t t2 ) const { return delta_s(t1,t2)*1e3; }
|
||||
@@ -206,6 +199,19 @@ class SG_EXPORT Timer {
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined (__APPLE__) || defined (macintosh)
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace osg{
|
||||
inline Timer_t Timer::tick() const
|
||||
{
|
||||
// Always uses std::clock()
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec;
|
||||
}
|
||||
}
|
||||
#elif defined(unix)
|
||||
|
||||
#include <sys/time.h>
|
||||
@@ -219,7 +225,7 @@ class SG_EXPORT Timer {
|
||||
}
|
||||
}
|
||||
|
||||
#elif !defined (__APPLE__) && !defined (macintosh)
|
||||
#else
|
||||
|
||||
// no choice, always use std::clock()
|
||||
namespace osg{
|
||||
@@ -229,6 +235,4 @@ class SG_EXPORT Timer {
|
||||
|
||||
#endif
|
||||
|
||||
// note, MacOSX compiled in the Timer.cpp.
|
||||
|
||||
#endif
|
||||
|
||||
@@ -285,27 +285,10 @@ const Timer* Timer::instance()
|
||||
|
||||
#elif defined (__APPLE__) || defined (macintosh)
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#include <Carbon/Carbon.h> // do I really have to link against the Carbon framework just for this?
|
||||
#else
|
||||
#include <MacTypes.h>
|
||||
#include <Timer.h>
|
||||
#endif
|
||||
|
||||
|
||||
Timer::Timer( void )
|
||||
Timer::Timer()
|
||||
{
|
||||
_useStandardClock = false;
|
||||
_secsPerTick = 1e-6; // Carbon timer's precision.
|
||||
|
||||
}
|
||||
|
||||
Timer_t Timer::tick(void) const
|
||||
{
|
||||
UnsignedWide usecs;
|
||||
Microseconds(&usecs);
|
||||
|
||||
return (usecs.hi * 4294967296.0) + usecs.lo;
|
||||
_useStandardClock = true;
|
||||
_secsPerTick = 1e-6; // gettimeofday()'s precision.
|
||||
}
|
||||
|
||||
#elif defined(unix)
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/malloc.h>
|
||||
#else
|
||||
// Where is malloc.h really needed?
|
||||
#if !defined(__APPLE__) && !defined(macintosh)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
@@ -602,10 +602,10 @@ inline int IsNaNorInf( float f )
|
||||
case FP_PINF : return 1;
|
||||
default : return 0;
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__linux) || defined(__CYGWIN__)
|
||||
#elif defined(__FreeBSD__) || defined(__APPLE__)
|
||||
return isnan(f) || isinf(f); // isnanf is deprecated
|
||||
#elif defined(__linux) || defined(__CYGWIN__)
|
||||
return isnanf(f) || isinf(f);
|
||||
#elif defined(__APPLE__)
|
||||
return __isnanf(f) || __isinf(f);
|
||||
#elif defined(__sun)
|
||||
return isnan(f); // KLUDGE - hack to get this to compile w/g++.
|
||||
#elif defined(WIN32)
|
||||
|
||||
@@ -56,12 +56,11 @@
|
||||
# pragma warning (disable:4541)
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/types.h>
|
||||
#include <sys/malloc.h>
|
||||
#else
|
||||
// Where is malloc.h really needed?
|
||||
#if !defined(__APPLE__) && !defined(macintosh)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "mynode.h"
|
||||
#include <stdlib.h>
|
||||
#include "geometry.h"
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
# pragma warning (disable:4541)
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/malloc.h>
|
||||
#else
|
||||
// Where is malloc.h really needed?
|
||||
#if !defined(__APPLE__) && !defined(macintosh)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "mynode.h"
|
||||
#include <stdlib.h>
|
||||
#include "geometry.h"
|
||||
|
||||
Reference in New Issue
Block a user