1 // Copyright (c) 1992-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.
15 #ifndef _OSD_HeaderFile
16 #define _OSD_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <Standard_Boolean.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_PCharacter.hxx>
26 #include <Standard_CString.hxx>
33 class OSD_FileIterator;
35 class OSD_DirectoryIterator;
38 class OSD_Environment;
39 class OSD_EnvironmentIterator;
41 class OSD_SharedLibrary;
45 //! Set of Operating Sytem Dependent Tools
46 //! (O)perating (S)ystem (D)ependent
54 //! Sets signal and exception handlers.
56 //! ### Windows-specific notes
58 //! Compiled with MS VC++ sets 3 main handlers:
59 //! @li Signal handlers (via ::signal() functions) that translate system signals
60 //! (SIGSEGV, SIGFPE, SIGILL) into C++ exceptions (classes inheriting
61 //! Standard_Failure). They only be called if user calls ::raise() function
62 //! with one of supported signal type set.
63 //! @li Exception handler OSD::WntHandler() (via ::SetUnhandledExceptionFilter())
64 //! that will be used when user's code is compiled with /EHs option.
65 //! @li Structured exception (SE) translator (via _set_se_translator()) that
66 //! translates SE exceptions (aka asynchronous exceptions) into the
67 //! C++ exceptions inheriting Standard_Failure. This translator will be
68 //! used when user's code is compiled with /EHa option.
70 //! This approach ensures that regardless of the option the user chooses to
71 //! compile his code with (/EHs or /EHa), signals (or SE exceptions) will be
72 //! translated into Open CASCADE C++ exceptions.
74 //! If @a theFloatingSignal is TRUE then floating point exceptions will be
75 //! generated in accordance with the mask
76 //! <tt>_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW</tt> that is
77 //! used to call ::_controlfp() system function. If @a theFloatingSignal is FALSE
78 //! corresponding operations (e.g. division by zero) will gracefully complete
79 //! without an exception.
81 //! ### Unix-specific notes
83 //! OSD::SetSignal() sets handlers (via ::sigaction()) for multiple signals
84 //! (SIGFPE, SIGSEGV, etc). Currently the number of handled signals is much
85 //! greater than for Windows, in the future this may change to provide better
86 //! consistency with Windows.
88 //! @a theFloatingSignal is recognized on Sun Solaris, Linux, and SGI Irix to
89 //! generate floating-point exception according to the mask
90 //! <tt>FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW</tt> (in Linux conventions).<br>
91 //! When compiled with OBJS macro defined, already set signal handlers (e.g.
92 //! by Data Base Managers) are not redefined.
96 //! If OSD::SetSignal() method is used in at least one thread, it must also be
97 //! called in any other thread where Open CASCADE will be used, to ensure
98 //! consistency of behavior. Its @a aFloatingSignal argument must be consistent
101 //! Keep in mind that whether the C++ exception will really be thrown (i.e.
102 //! ::throw() will be called) is regulated by the
103 //! OCC_CONVERT_SIGNALS macro used during compilation of Open CASCADE and
104 //! user's code. Refer to Foundation Classes User's Guide for further details.
106 Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
108 //! Commands the process to sleep for a number of seconds.
109 Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
111 //! Commands the process to sleep for a number of milliseconds
112 Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay);
114 //! Converts aReal into aCstring in exponential format with a period as
115 //! decimal point, no thousand separator and no grouping of digits.
116 //! The conversion is independant from the current locale
117 Standard_EXPORT static Standard_Boolean RealToCString (const Standard_Real aReal, Standard_PCharacter& aString);
119 //! Converts aCstring representing a real with a period as
120 //! decimal point, no thousand separator and no grouping of digits
122 //! The conversion is independant from the current locale.
123 Standard_EXPORT static Standard_Boolean CStringToReal (const Standard_CString aString, Standard_Real& aReal);
125 //! since Windows NT does not support 'SIGINT' signal like UNIX,
126 //! then this method checks whether Ctrl-Break keystroke was or
127 //! not. If yes then raises Exception_CTRL_BREAK.
128 Standard_EXPORT static void ControlBreak();
132 #endif // _OSD_HeaderFile