From e73d4ca5b3d16e8d12bc3d61ce9f74fb22e1003f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 28 May 2002 11:40:37 +0000 Subject: [PATCH] Changes for Cygwin build, sent in by Norman Vine. --- include/osg/Export | 2 +- include/osg/Timer | 130 +++++++++++++------------ include/osgDB/Export | 2 +- include/osgText/Export | 2 +- include/osgUtil/Export | 2 +- src/Demos/hangglide/hat.cpp | 2 +- src/Demos/hangglide/sky.cpp | 2 +- src/Demos/hangglide/tank.cpp | 2 +- src/Demos/hangglide/trees.cpp | 2 +- src/osg/Image.cpp | 2 +- src/osgDB/FileUtils_Unix.cpp | 9 +- src/osgPlugins/flt/Pool.cpp | 2 +- src/osgPlugins/flt/ReaderWriterFLT.cpp | 2 +- src/osgText/FTGL.h | 2 +- src/osgText/Font.cpp | 2 +- 15 files changed, 85 insertions(+), 80 deletions(-) diff --git a/include/osg/Export b/include/osg/Export index b8e548b90..685e41d20 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -5,7 +5,7 @@ #ifndef OSG_EXPORT #define OSG_EXPORT 1 -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +#if defined(_MSC_VER) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) diff --git a/include/osg/Timer b/include/osg/Timer index db1a2d1ff..d99911a15 100644 --- a/include/osg/Timer +++ b/include/osg/Timer @@ -8,7 +8,7 @@ #include -#if defined(WIN32 ) && !(defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MWERKS__)) +#if defined(_MSC_VER) namespace osg { typedef __int64 Timer_t; } @@ -73,41 +73,44 @@ class SG_EXPORT Timer { } -#if defined(_WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MWERKS__)) +#if defined(_MSC_VER) + #include #pragma optimize("",off) -namespace osg{ + namespace osg{ - inline Timer_t Timer::tick( void ) const - { - if (_useStandardClock) return clock(); - - volatile Timer_t ts; - volatile unsigned int HighPart; - volatile unsigned int LowPart; - _asm + inline Timer_t Timer::tick( void ) const { - xor eax, eax // Used when QueryPerformanceCounter() - xor edx, edx // not supported or minimal overhead - _emit 0x0f // desired - _emit 0x31 // - mov HighPart,edx - mov LowPart,eax + if (_useStandardClock) return clock(); + + volatile Timer_t ts; + volatile unsigned int HighPart; + volatile unsigned int LowPart; + _asm + { + xor eax, eax // Used when QueryPerformanceCounter() + xor edx, edx // not supported or minimal overhead + _emit 0x0f // desired + _emit 0x31 // + mov HighPart,edx + mov LowPart,eax + } + //ts = LowPart | HighPart >> 32; + *((unsigned int*)&ts) = LowPart; + *((unsigned int*)&ts+1) = HighPart; + return ts; } - //ts = LowPart | HighPart >> 32; - *((unsigned int*)&ts) = LowPart; - *((unsigned int*)&ts+1) = HighPart; - return ts; + } - -} #pragma optimize("",on) -#elif defined(__MINGW32__) -#include -#define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)) -namespace osg{ +#elif defined(__MINGW32__) + + #include + + #define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)) + namespace osg{ inline Timer_t Timer::tick() const { @@ -119,72 +122,73 @@ namespace osg{ } } -} + } + #elif defined(__linux) || defined(__FreeBSD__) || defined(__CYGWIN__) #include #define CLK(x) __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)) -namespace osg{ + namespace osg{ - inline Timer_t Timer::tick() const - { - if (_useStandardClock) + inline Timer_t Timer::tick() const { - struct timeval tv; - gettimeofday(&tv, NULL); - return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; - } - else - { - Timer_t x;CLK(x);return x; + if (_useStandardClock) + { + struct timeval tv; + gettimeofday(&tv, NULL); + return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; + } + else + { + Timer_t x;CLK(x);return x; + } } + } - -} #elif defined(__sgi) #include -namespace osg{ + namespace osg{ - inline Timer_t Timer::tick() const - { - if (_useStandardClock) + inline Timer_t Timer::tick() const { - struct timeval tv; - gettimeofday(&tv, NULL); - return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; - } - else - { - return *_clockAddress; + if (_useStandardClock) + { + struct timeval tv; + gettimeofday(&tv, NULL); + return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; + } + else + { + return *_clockAddress; + } } } -} #elif defined(unix) #include -namespace osg{ - inline Timer_t Timer::tick() const - { - struct timeval tv; - gettimeofday(&tv, NULL); - return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; + namespace osg{ + inline Timer_t Timer::tick() const + { + struct timeval tv; + gettimeofday(&tv, NULL); + return ((osg::Timer_t)tv.tv_sec)*1000000+(osg::Timer_t)tv.tv_usec; + } } -} #elif !defined (__DARWIN_OSX__) && !defined (macintosh) // no choice, always use std::clock() -namespace osg{ + namespace osg{ - inline Timer_t Timer::tick( void ) const { return std::clock(); } -} + inline Timer_t Timer::tick( void ) const { return std::clock(); } + } #endif diff --git a/include/osgDB/Export b/include/osgDB/Export index 0e23be035..ed6051fea 100644 --- a/include/osgDB/Export +++ b/include/osgDB/Export @@ -5,7 +5,7 @@ #ifndef OSGDB_EXPORT_ #define OSGDB_EXPORT_ 1 -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +#if defined(_MSC_VER) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) diff --git a/include/osgText/Export b/include/osgText/Export index 0b710b438..7488ec829 100644 --- a/include/osgText/Export +++ b/include/osgText/Export @@ -5,7 +5,7 @@ #ifndef OSGTEXT_EXPORT_ #define OSGTEXT_EXPORT_ 1 -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +#if defined(_MSC_VER) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) diff --git a/include/osgUtil/Export b/include/osgUtil/Export index 985fc5d9e..38b826e17 100644 --- a/include/osgUtil/Export +++ b/include/osgUtil/Export @@ -6,7 +6,7 @@ #ifndef OSGUTIL_EXPORT_ #define OSGUTIL_EXPORT_ 1 -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +#if defined(_MSC_VER) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) diff --git a/src/Demos/hangglide/hat.cpp b/src/Demos/hangglide/hat.cpp index 4ac730ea4..f5e3e219f 100644 --- a/src/Demos/hangglide/hat.cpp +++ b/src/Demos/hangglide/hat.cpp @@ -1,4 +1,4 @@ -#ifdef WIN32 +#ifdef _MSC_VER #include #pragma warning( disable : 4244 ) #endif diff --git a/src/Demos/hangglide/sky.cpp b/src/Demos/hangglide/sky.cpp index 0117a647c..858c53131 100644 --- a/src/Demos/hangglide/sky.cpp +++ b/src/Demos/hangglide/sky.cpp @@ -9,7 +9,7 @@ #include -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif diff --git a/src/Demos/hangglide/tank.cpp b/src/Demos/hangglide/tank.cpp index 468ffcc26..d1e1893a5 100644 --- a/src/Demos/hangglide/tank.cpp +++ b/src/Demos/hangglide/tank.cpp @@ -11,7 +11,7 @@ #include -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif diff --git a/src/Demos/hangglide/trees.cpp b/src/Demos/hangglide/trees.cpp index 89492da15..7f97c84a6 100644 --- a/src/Demos/hangglide/trees.cpp +++ b/src/Demos/hangglide/trees.cpp @@ -13,7 +13,7 @@ #include "hat.h" -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index a1a04a7ef..d2d80f002 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -297,7 +297,7 @@ void Image::scaleImage(const int s,const int t,const int r) if (!newData) { // should we throw an exception??? Just return for time being. - notify(FATAL) << "Error Image::scaleImage() do not succeed : out of memory."<