1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
17 // Convert Real to CString in format e with 16 significant digits.
18 // The decimal point character is always a period.
19 // The conversion is independant from current locale database
21 Standard_Boolean OSD::RealToCString(const Standard_Real aReal,
22 Standard_PCharacter& aString)
26 if (Sprintf(aString,"%.17e",aReal) <= 0) //BUC60808
27 return Standard_False ;
29 // Suppress "e+00" and unsignificant 0's
31 p = strchr(aString,'e');
33 if (!strcmp(p,"e+00"))
35 for (q = p-1 ; *q == '0' ; q--) ;
43 return Standard_True ;
46 // Make the RealToCString reciprocal conversion.
48 Standard_Boolean OSD::CStringToReal(const Standard_CString aString,
52 aReal = Strtod(aString, &endptr);
54 return Standard_False ;
58 //=======================================================================
59 //function : OSDSecSleep
60 //purpose : Cause the process to sleep during a amount of seconds
61 //=======================================================================
65 # define SLEEP(NSEC) Sleep(1000*(NSEC))
68 # define SLEEP(NSEC) sleep(NSEC)
71 void OSD::SecSleep(const Standard_Integer aDelay)
76 //=======================================================================
77 //function : MilliSecSleep
78 //purpose : Cause the process to sleep during a amount of milliseconds
79 //=======================================================================
83 void OSD::MilliSecSleep(const Standard_Integer aDelay)
92 void OSD::MilliSecSleep(const Standard_Integer aDelay)
94 struct timeval timeout ;
96 timeout.tv_sec = aDelay / 1000 ;
97 timeout.tv_usec = (aDelay % 1000) * 1000 ;
99 select(0,NULL,NULL,NULL,&timeout) ;