0030091: Configuration - allow cross-compilation from Linux (case sensitive filesyste...
[occt.git] / src / OSD / OSD.cxx
index 7b75cab..b8c9757 100644 (file)
@@ -3,8 +3,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <OSD.ixx>
-#include <Standard_Stream.hxx>
-#include <stdio.h>
-#include <math.h>
-#if HAVE_IEEEFP_H
-# include <ieeefp.h>
-#endif
-#if !defined(HAVE_FINITE) && defined(isfinite)
-# define finite isfinite
-#endif
+#include <OSD.hxx>
 
 // Convert Real to CString in format e with 16 significant digits.
 // The decimal point character is always a period.
@@ -69,28 +60,14 @@ Standard_Boolean OSD::CStringToReal(const Standard_CString aString,
 //purpose  : Cause the process to sleep during a amount of seconds 
 //=======================================================================
 
-#ifdef WNT
-# include <Windows.h>
-#if !defined(__CYGWIN32__) && !defined(__MINGW32__)
-//# include <Mapiwin.h>
-#endif
-# define _DEXPLEN                   11
-# define _IEEE                       1
-# define DMAXEXP                    ((1 << _DEXPLEN - 1) - 1 + _IEEE)
-# define finite                      _finite
+#ifdef _WIN32
+# include <windows.h>
 # define SLEEP(NSEC)                 Sleep(1000*(NSEC))
 #else
+#include <unistd.h>
 # define SLEEP(NSEC)                 sleep(NSEC)
 #endif
 
-#ifdef HAVE_VALUES_H
-//# include <values.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
 void OSD::SecSleep(const Standard_Integer aDelay)
 {
   SLEEP(aDelay);
@@ -101,7 +78,7 @@ void OSD::SecSleep(const Standard_Integer aDelay)
 //purpose  : Cause the process to sleep during a amount of milliseconds  
 //=======================================================================
 
-#ifdef WNT
+#ifdef _WIN32
 
 void OSD::MilliSecSleep(const Standard_Integer aDelay)
 {
@@ -110,9 +87,7 @@ void OSD::MilliSecSleep(const Standard_Integer aDelay)
 
 #else
 
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
+#include <sys/time.h>
 
 void OSD::MilliSecSleep(const Standard_Integer aDelay)
 {
@@ -125,134 +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)
-{
-  if ( theDivisor == 0. || ! finite(theDividend) ) return Standard_False;
-  //
-  // you may divide by infinity
-  //
-  if (! finite(theDivisor)) return Standard_True;
-#ifdef DEB
-//   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 <stdlib.h>
-#include <stdio.h>
-#include <malloc.h>
-
-# if defined(SUN) || defined(__sun) || defined(SOLARIS)
-#  define SIZE_MAX  0x7fffffff
-# elif defined(__osf__)  || defined(DECOSF1)        
-#  define SIZE_MAX  0x10000000000 
-# elif defined(WNT)
-#  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