1 -- Copyright (c) 1992-1999 Matra Datavision
2 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
4 -- The content of this file is subject to the Open CASCADE Technology Public
5 -- License Version 6.5 (the "License"). You may not use the content of this file
6 -- except in compliance with the License. Please obtain a copy of the License
7 -- at http://www.opencascade.org and read it completely before using this file.
9 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 -- The Original Code and all software distributed under the License is
13 -- distributed on an "AS IS" basis, without warranty of any kind, and the
14 -- Initial Developer hereby disclaims all such warranties, including without
15 -- limitation, any warranties of merchantability, fitness for a particular
16 -- purpose or non-infringement. Please see the License for the specific terms
17 -- and conditions governing the rights and limitations under the License.
20 -- 20-01-2009 : ABD Integration support of system fonts (using FTGL and FreeType)
25 -- Version Date Purpose
26 -- 1.1 24/06/92 Operating System Dependent tools
30 -- Windows NT 30/09/96 ( EUG )
31 ---Purpose: Set of Operating Sytem Dependent Tools
32 -- (O)perating (S)ystem (D)ependent
42 exception OSDError inherits Failure from Standard ;
45 ---Purpose: This is in fact a pointer to a function.
46 -- This is not an "enumeration" but a trick to solve an omission
48 --- C++: alias "typedef int (* OSD_Function)(...);"
50 enumeration OEMType is Unavailable,SUN,DEC,SGI,NEC,MAC,PC,HP,IBM,VAX,LIN,AIX;
51 ---Purpose: This is set of possible machine types
52 -- used in OSD_Host::MachineType
54 enumeration SysType is Unknown,Default,UnixBSD, UnixSystemV, VMS, OS2,
55 OSF, MacOs, Taligent, WindowsNT, LinuxREDHAT,Aix;
56 ---Purpose: Thisd is a set of possible system types.
57 -- 'Default' means SysType of machine operating this process.
58 -- This can be used with the Path class.
59 -- All UNIX-like are grouped under "UnixBSD" or "UnixSystemV".
60 -- Such systems are Solaris, NexTOS ...
61 -- A category of systems accept MSDOS-like path such as
64 enumeration FromWhere is FromBeginning, FromHere, FromEnd;
65 ---Purpose: Used by OSD_File in the method Seek.
67 enumeration LockType is NoLock, ReadLock, WriteLock, ExclusiveLock;
68 ---Purpose: locks for files.
69 -- NoLock is the default value when opening a file.
71 -- ReadLock allows only one reading of the file at a time.
73 -- WriteLock prevents others writing into a file(excepted the user
74 -- who puts the lock)but allows everybody to read.
76 -- ExclusiveLock prevents reading and writing except for the
77 -- current user of the file.
78 -- So ExclusiveLock means only one user on the file and this
79 -- user is the one who puts the lock.
81 enumeration SingleProtection is None,R,W,RW,X,RX,WX,RWX,D,RD,WD,RWD,XD,RXD,WXD,RWXD;
82 ---Purpose: Access rights for files.
83 -- R means Read, W means Write, X means eXecute and D means Delete.
84 -- On UNIX, the right to Delete is combined with Write access.
85 -- So if "W"rite is not set and "D"elete is, "W"rite will be set
86 -- and if "W" is set, "D" will be too.
88 enumeration OpenMode is ReadOnly, WriteOnly, ReadWrite;
89 ---Purpose: Specifies the file open mode.
91 enumeration LoadMode is RTLD_LAZY, RTLD_NOW;
92 ---Purpose: This enumeration is used to load shareable libraries.
94 enumeration KindFile is FILE, DIRECTORY, LINK, SOCKET, UNKNOWN;
95 ---Purpose: Specifies the type of files.
97 private enumeration WhoAmI is WDirectory, WDirectoryIterator,
98 WEnvironment, WFile, WFileNode, WFileIterator, WMailBox,
99 WPath, WProcess, WProtection, WSemaphore, WHost, WDisk,
100 WChronometer, WSharedMemory, WTimer, WPackage, WPrinter,
101 WEnvironmentIterator;
102 ---Purpose: Allows great accuracy for error management.
107 ---Purpose: Accurate management of OSD specific errors.
110 ---Purpose: Gets and sets protection attributes of 'system , user ,
111 -- group, and world'.
114 ---Purpose: Manages independent system path translation.
116 deferred class FileNode;
117 ---Purpose: A set of file/directory manipulation tools.
120 ---Purpose: A set of disk oriented tools.
123 ---Purpose: A set of file oriented tools.
126 ---Purpose: Searches for child files in current directory.
129 ---Purpose: A set of directory oriented tools
131 class DirectoryIterator;
132 ---Purpose: Searches sub-directories in current directory.
135 ---Purpose: Measures time elapsed for performance program tests.
136 -- Measures CPU time consumed by a method call.
139 ---Purpose: Measures the effective time elapsed for a method call.
142 ---Purpose: Selects a printer (used by File).
145 ---Purpose: Carries information about a host.
146 -- System version ,host name, nodename ...
149 ---Purpose: Manages environment variables.
151 class EnvironmentIterator;
152 ---Purpose: Get all environment variables.
155 ---Purpose: Process specific oriented tools
158 ---Purpose: Manages shared memory.
161 ---Purpose: Manages semaphores.
163 -- class Mutex is alias Mutex from Standard;
164 ---Purpose: Mutex object to synchronize threads within one process
167 ---Purpose: Manages asynchronous mail boxes.
170 ---Purpose: Provides tools to load a shared library
171 -- and retrieve the address of an entry point.
175 imported ThreadFunction;
177 ---Purpose: A tool to manage threads
180 ---Purpose: Convertion of CString to Real and reciprocally
183 ---Purpose: Manages locale.
186 -----------------------------------------------
187 -- UNIX specific exceptions and enumeration --
188 -----------------------------------------------
190 exception Signal inherits Failure from Standard;
191 exception SIGHUP inherits Signal;
192 exception SIGINT inherits Signal;
193 exception SIGQUIT inherits Signal;
194 exception SIGILL inherits Signal;
195 exception SIGKILL inherits Signal;
196 exception SIGBUS inherits Signal;
197 exception SIGSEGV inherits Signal;
198 exception SIGSYS inherits Signal;
201 enumeration Signals is
203 -- The "posix" signals.
205 S_SIGHUP, -- "hangup."
206 S_SIGINT, -- "interrupt."
207 S_SIGQUIT, -- "quit."
208 S_SIGILL, -- "illegal instruction."
209 S_SIGKILL, -- "kill."
210 S_SIGBUS, -- "bus error."
211 S_SIGSEGV, -- "segmentation violation."
212 S_SIGSYS, -- "bad argument to system call."
213 S_SIGFPE, -- "floating point exception."
214 S_FPE_FLTDIV_TRAP, -- "floating/decimal divide by zero."
215 S_FPE_INTDIV_TRAP, -- "integer divide by zero."
216 S_FPE_FLTOVF_TRAP, -- "floating overflow."
217 S_FPE_INTOVF_TRAP, -- "integer overflow."
218 S_FPE_FLTUND_TRAP, -- "floating underflow."
219 S_FPE_FLTINEX_TRAP -- "floating inexact result."
222 ----------------------------------------
223 -- Exceptions ( Windows NT specific ) --
224 ----------------------------------------
226 exception Exception inherits Failure from Standard;
228 exception Exception_ACCESS_VIOLATION inherits Exception;
229 exception Exception_ARRAY_BOUNDS_EXCEEDED inherits Exception;
230 exception Exception_FLT_DENORMAL_OPERAND inherits Exception;
231 exception Exception_FLT_DIVIDE_BY_ZERO inherits Exception;
232 exception Exception_FLT_INEXACT_RESULT inherits Exception;
233 exception Exception_FLT_INVALID_OPERATION inherits Exception;
234 exception Exception_FLT_OVERFLOW inherits Exception;
235 exception Exception_FLT_STACK_CHECK inherits Exception;
236 exception Exception_FLT_UNDERFLOW inherits Exception;
237 exception Exception_ILLEGAL_INSTRUCTION inherits Exception;
238 exception Exception_IN_PAGE_ERROR inherits Exception;
239 exception Exception_INT_DIVIDE_BY_ZERO inherits Exception;
240 exception Exception_INT_OVERFLOW inherits Exception;
241 exception Exception_INVALID_DISPOSITION inherits Exception;
242 exception Exception_NONCONTINUABLE_EXCEPTION inherits Exception;
243 exception Exception_PRIV_INSTRUCTION inherits Exception;
244 exception Exception_STACK_OVERFLOW inherits Exception;
245 exception Exception_STATUS_NO_MEMORY inherits Exception; -- generating by 'HeapAlloc'
246 exception Exception_CTRL_BREAK inherits Exception; -- generating by 'Ctrl-C' keystroke
248 ----------------------------------------------
249 -- Handler and SegvHandler (UNIX specific ) --
250 ----------------------------------------------
253 -- Handler(aSignal: Signals; aCode: Signals)
256 Handler(aSignal: Signals; aSigInfo: Address; aContext: Address)
258 -- 1) Raise a exception when aSignal is a floating point signal.
259 -- aSignal is SIGFPE.
261 -- (FPE: Floating Point Exception)
262 -- (FLT: FLoaTing operation.)
263 -- (INT: INTeger operation.)
264 -- (DIV: DIVided by zero.)
266 -- (INEX: INEXact operation.)
268 -- FPE_FLTDIV_TRAP (the exception "DivideByZero" is raised.)
269 -- FPE_INTDIV_TRAP (the exception "DivideByZero" is raised.)
271 -- FPE_FLTOVF_TRAP (the exception "Overflow" is raised.)
272 -- FPE_INTOVF_TRAP (the exception "Overflow" is raised.)
274 -- FPE_FLTINEX_TRAP (the exception "NumericError" is raised.)
276 -- 2) Display the signal name, and call "exit" with signal number for
277 -- a "Hardware" signal.
293 SegvHandler(aSignal: Signals; aSigInfo: Address; aContext: Address)
295 -- Handle access to null object and segmentation violation
302 ---------------------------------------
303 -- WntHandler (Windows NT specific ) --
304 ---------------------------------------
306 WntHandler ( exceptionInfo : Address from Standard )
307 returns Integer from Standard
311 Exception_ACCESS_VIOLATION,
312 Exception_ARRAY_BOUNDS_EXCEEDED,
313 Exception_FLT_DENORMAL_OPERAND,
314 Exception_FLT_DIVIDE_BY_ZERO,
315 Exception_FLT_INEXACT_RESULT,
316 Exception_FLT_INVALID_OPERATION,
317 Exception_FLT_OVERFLOW,
318 Exception_FLT_STACK_CHECK,
319 Exception_FLT_UNDERFLOW,
320 Exception_ILLEGAL_INSTRUCTION,
321 Exception_IN_PAGE_ERROR,
322 Exception_INVALID_DISPOSITION,
323 Exception_NONCONTINUABLE_EXCEPTION,
324 Exception_PRIV_INSTRUCTION,
325 Exception_STACK_OVERFLOW,
326 Exception_STATUS_NO_MEMORY
329 -- 1) Raises an exception if the exception due to floating point errors.
330 -- Flosting point errors:
331 -- EXCEPTION_FLT_DENORMAL_OPERAND
332 -- EXCEPTION_FLT_DIVIDE_BY_ZERO
333 -- EXCEPTION_FLT_INEXACT_RESULT
334 -- EXCEPTION_FLT_INVALID_OPERATION
335 -- EXCEPTOPN_FLT_OVERFLOW
336 -- EXCEPTION_FLT_STACK_CHECK
337 -- EXCEPTION_FLT_UNDERFLOW
338 -- 2) Displays a message box 'Continue' - 'Debugger' - 'Stop' if the environment
339 -- variable 'CSF_EXCEPTION_PROMPT' is set and takes appropriate action.
340 -- Raises an exception otherwise.
342 SetSignal(aFloatingSignal: Boolean = Standard_True);
344 -- 1) Arms some floating point signals, and sets a "Handler" for them.
345 -- 2) Sets a "Handler" for the "Hardware" signals.
346 -- For Win32 users: under VC++ you can control which method of handling
347 -- exceptions is used by means of UseSETranslator method before calling
351 -- Some "Data Base Managers" use their own "Handler" for the signals
352 -- such as "SIGSEGV". So if a "Handler" is set for a signal it will
353 -- not be replaced by Standard "Handler". It is managed by OBJS
354 -- preprocessor definition.
358 AvailableMemory returns Integer from Standard;
359 ---Purpose: Returns available memory in Kilobytes.
362 SecSleep(aDelay: Integer from Standard);
363 ---Purpose: Commands the process to sleep for a number of seconds.
366 MilliSecSleep(aDelay: Integer from Standard);
367 ---Purpose: Commands the process to sleep for a number of milliseconds
370 RealToCString(aReal: Real; aString:out PCharacter)
373 -- Converts aReal into aCstring in exponential format with a period as
374 -- decimal point, no thousand separator and no grouping of digits.
375 -- The conversion is independant from the current locale
378 CStringToReal(aString: CString; aReal: out Real) returns Boolean ;
380 -- Converts aCstring representing a real with a period as
381 -- decimal point, no thousand separator and no grouping of digits
383 -- The conversion is independant from the current locale.
386 IsDivisible(aDividend, aDivisor: Real from Standard)
387 returns Boolean from Standard;
388 ---Purpose: Tests if the quotient theDividend/theDivisor
392 GetExponent(aReal: Real from Standard)
393 returns Integer from Standard;
394 ---Purpose: Returns the exponent in base 2 of a floating-point number.
397 GetMantissa(aReal: Real from Standard)
398 returns Real from Standard;
399 ---Purpose: Returns the mantissa of a floating-point number.
402 -------------------------
403 -- Windows NT specific --
404 -------------------------
406 ControlBreak raises Exception_CTRL_BREAK;
407 ---Purpose: since Windows NT does not support 'SIGINT' signal like UNIX,
408 -- then this method checks whether Ctrl-Break keystroke was or
409 -- not. If yes then raises Exception_CTRL_BREAK.
411 UseSETranslator(useSE : Boolean);
412 ---Purpose: Defines whether SetSignal must use _se_translator_function or
413 -- SetUnhandledExceptionFilter and signal to catch system
414 -- exceptions. The default behaviour is to use SE translator.
415 -- Warning: Using SE translator method SetSignal should be called for each
416 -- new created thread, while using the alternative method
417 -- the exception handler is established once for the whole
418 -- process and all its threads.
419 -- This function takes effect only under VC++ compiler.
421 UseSETranslator returns Boolean;
422 ---Purpose: Returns the current value of the flag set by above method.