diff --git a/src/OSD/OSD.cxx b/src/OSD/OSD.cxx index 6a6a4d0d79..38a28e6c28 100644 --- a/src/OSD/OSD.cxx +++ b/src/OSD/OSD.cxx @@ -12,15 +12,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include - -#include -#include -#if defined(isfinite) -# define finite isfinite -#endif // Convert Real to CString in format e with 16 significant digits. // The decimal point character is always a period. @@ -70,19 +62,10 @@ Standard_Boolean OSD::CStringToReal(const Standard_CString aString, #ifdef _WIN32 # include -#if !defined(__CYGWIN32__) && !defined(__MINGW32__) -//# include -#endif -# define _DEXPLEN 11 -# define _IEEE 1 -# define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) -# define finite _finite # define SLEEP(NSEC) Sleep(1000*(NSEC)) #else -# define SLEEP(NSEC) sleep(NSEC) -#endif -#ifndef _WIN32 #include +# define SLEEP(NSEC) sleep(NSEC) #endif void OSD::SecSleep(const Standard_Integer aDelay) @@ -117,138 +100,3 @@ void OSD::MilliSecSleep(const Standard_Integer aDelay) } #endif - -//======================================================================= -//function : IsDivisible -//purpose : -//======================================================================= - -Standard_Boolean OSD::IsDivisible(const Standard_Real theDividend,const Standard_Real theDivisor) -{ -#ifdef __QNX__ - using std::finite; -#endif - - if ( theDivisor == 0. || ! finite(theDividend) ) return Standard_False; - // - // you may divide by infinity - // - if (! finite(theDivisor)) return Standard_True; -#ifdef OCCT_DEBUG -// Standard_Integer aExp1, aExp2; -// Standard_Real aMant1 = frexp(theDividend, &aExp1); -// Standard_Real aMant2 = frexp(theDivisor, &aExp2); -#endif -// Code de :KL:dev:ref : -// return ((aExp1-aExp2 < DMAXEXP) || // exponent of the result -// (aExp1-aExp2 == DMAXEXP && aMant1 < aMant2)) ; - -// Code de :KAS:C30 : - return Standard_True; - - -// this is unacceptable return for Linux because of (temporary?) undefined aExp1 and aExp2. -// Testing both over and underflow should be (:KL:dev ) : - -// return ((aExp1-aExp2 < DMAXEXP) && (aExp1-aExp2 > DMINEXP) || -// (aExp1-aExp2 == DMAXEXP && aMant1 < aMant2) || -// (aExp1-aExp2 == DMINEXP && aMant1 > aMant2)) ; -} - -//======================================================================= -//function : GetExponent -//purpose : -//======================================================================= - -//Standard_Integer OSD::GetExponent(const Standard_Real aReal) -Standard_Integer OSD::GetExponent(const Standard_Real ) -{ -// Code de :KAS:C30 : - - cout << "Function OSD::GetExponent() not yet implemented." << endl; - return 0 ; - -// Code de :KL:dev:ref : - -// Standard_Integer Exp ; - -//// Standard_Real Mant = frexp(aReal, &Exp) ; -// frexp(aReal, &Exp) ; -// return Exp ; -} - -//======================================================================= -//function : GetMantissa -//purpose : -//======================================================================= - -//Standard_Real OSD::GetMantissa(const Standard_Real aReal) -Standard_Real OSD::GetMantissa(const Standard_Real ) -{ -// Code de :KAS:C30 : - cout << "Function OSD::GetMantissa() not yet implemented." << endl; - return 0 ; - -// Code de :KL:dev:ref : - -// Standard_Integer Exp ; -// return frexp(aReal, &Exp) ; -} - -//======================================================================= -// Code de :KAS:C30 : -//======================================================================= -Standard_Integer OSD::AvailableMemory() -{ - cout << "Function OSD::AvailableMemory() not yet implemented." << endl; - return 0 ; -} - -// Code de :KL:dev:ref ??????????????? : -#if 0 -//======================================================================= -//function : AvailableMemory -//purpose : -//======================================================================= -#include -#include -#include - -# if defined(SUN) || defined(__sun) || defined(SOLARIS) -# define SIZE_MAX 0x7fffffff -# elif defined(__osf__) || defined(DECOSF1) -# define SIZE_MAX 0x10000000000 -# elif defined(_WIN32) -# define SIZE_MAX 0x7ffdefff -# else -# define SIZE_MAX 0xffffffff -# endif - -Standard_Integer OSD::AvailableMemory() -{ - size_t min = 1024 ; - size_t max = SIZE_MAX ; - size_t middle = SIZE_MAX ; - void * addr ; - int nballoc = 0 ; - int nbfree = 0 ; - - while (min + 1024 < max) { - if ((addr = malloc (middle))== (void *)-1) { - perror("OSD::AvailableMemory()_malloc error :") ; - return 0 ; - } - nballoc++ ; - if (addr == 0) - max = middle ; - else { - free(addr) ; - nbfree++ ; - min = middle ; - } - middle = min + ((max - min ) >> 6) * 63 ; - } - return min >> 10 ; -} - -#endif diff --git a/src/OSD/OSD.hxx b/src/OSD/OSD.hxx index fca3d5d8bd..024633b010 100644 --- a/src/OSD/OSD.hxx +++ b/src/OSD/OSD.hxx @@ -104,21 +104,16 @@ public: //! user's code. Refer to Foundation Classes User's Guide for further details. Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True); - //! Returns available memory in Kilobytes. - Standard_EXPORT static Standard_Integer AvailableMemory(); - //! Commands the process to sleep for a number of seconds. Standard_EXPORT static void SecSleep (const Standard_Integer aDelay); //! Commands the process to sleep for a number of milliseconds Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay); - //! Converts aReal into aCstring in exponential format with a period as //! decimal point, no thousand separator and no grouping of digits. //! The conversion is independant from the current locale Standard_EXPORT static Standard_Boolean RealToCString (const Standard_Real aReal, Standard_PCharacter& aString); - //! Converts aCstring representing a real with a period as //! decimal point, no thousand separator and no grouping of digits @@ -126,60 +121,11 @@ public: //! The conversion is independant from the current locale. Standard_EXPORT static Standard_Boolean CStringToReal (const Standard_CString aString, Standard_Real& aReal); - //! Tests if the quotient theDividend/theDivisor - //! does not overflow - Standard_EXPORT static Standard_Boolean IsDivisible (const Standard_Real aDividend, const Standard_Real aDivisor); - - //! Returns the exponent in base 2 of a floating-point number. - Standard_EXPORT static Standard_Integer GetExponent (const Standard_Real aReal); - - //! Returns the mantissa of a floating-point number. - Standard_EXPORT static Standard_Real GetMantissa (const Standard_Real aReal); - //! since Windows NT does not support 'SIGINT' signal like UNIX, //! then this method checks whether Ctrl-Break keystroke was or //! not. If yes then raises Exception_CTRL_BREAK. Standard_EXPORT static void ControlBreak(); - - - -protected: - - - - - -private: - - - - -friend class OSD_Error; -friend class OSD_Protection; -friend class OSD_Path; -friend class OSD_FileNode; -friend class OSD_Disk; -friend class OSD_File; -friend class OSD_FileIterator; -friend class OSD_Directory; -friend class OSD_DirectoryIterator; -friend class OSD_Chronometer; -friend class OSD_Timer; -friend class OSD_Printer; -friend class OSD_Host; -friend class OSD_Environment; -friend class OSD_EnvironmentIterator; -friend class OSD_Process; -friend class OSD_SharedLibrary; -friend class OSD_Thread; - }; - - - - - - #endif // _OSD_HeaderFile