1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
-- File: OSD.cdl
-- Copyright: Matra Datavision 1992,1995
-- Update:
-- 20-01-2009 : ABD Integration support of system fonts (using FTGL and FreeType)
package OSD
---History:
-- Version Date Purpose
-- 1.1 24/06/92 Operating System Dependent tools
-- 1.2
-- 2.0
-- 3.0
-- Windows NT 30/09/96 ( EUG )
---Purpose: Set of Operating Sytem Dependent Tools
-- (O)perating (S)ystem (D)ependent
uses
Standard ,
Quantity ,
TCollection
is
exception OSDError inherits Failure from Standard ;
imported Function;
---Purpose: This is in fact a pointer to a function.
-- This is not an "enumeration" but a trick to solve an omission
-- from CDL.
--- C++: alias "typedef int (* OSD_Function)(...);"
enumeration OEMType is Unavailable,SUN,DEC,SGI,NEC,MAC,PC,HP,IBM,VAX,LIN,AIX;
---Purpose: This is set of possible machine types
-- used in OSD_Host::MachineType
enumeration SysType is Unknown,Default,UnixBSD, UnixSystemV, VMS, OS2,
OSF, MacOs, Taligent, WindowsNT, LinuxREDHAT,Aix;
---Purpose: Thisd is a set of possible system types.
-- 'Default' means SysType of machine operating this process.
-- This can be used with the Path class.
-- All UNIX-like are grouped under "UnixBSD" or "UnixSystemV".
-- Such systems are Solaris, NexTOS ...
-- A category of systems accept MSDOS-like path such as
-- WindowsNT and OS2.
enumeration FromWhere is FromBeginning, FromHere, FromEnd;
---Purpose: Used by OSD_File in the method Seek.
enumeration LockType is NoLock, ReadLock, WriteLock, ExclusiveLock;
---Purpose: locks for files.
-- NoLock is the default value when opening a file.
--
-- ReadLock allows only one reading of the file at a time.
--
-- WriteLock prevents others writing into a file(excepted the user
-- who puts the lock)but allows everybody to read.
--
-- ExclusiveLock prevents reading and writing except for the
-- current user of the file.
-- So ExclusiveLock means only one user on the file and this
-- user is the one who puts the lock.
enumeration SingleProtection is None,R,W,RW,X,RX,WX,RWX,D,RD,WD,RWD,XD,RXD,WXD,RWXD;
---Purpose: Access rights for files.
-- R means Read, W means Write, X means eXecute and D means Delete.
-- On UNIX, the right to Delete is combined with Write access.
-- So if "W"rite is not set and "D"elete is, "W"rite will be set
-- and if "W" is set, "D" will be too.
enumeration OpenMode is ReadOnly, WriteOnly, ReadWrite;
---Purpose: Specifies the file open mode.
enumeration LoadMode is RTLD_LAZY, RTLD_NOW;
---Purpose: This enumeration is used to load shareable libraries.
enumeration KindFile is FILE, DIRECTORY, LINK, SOCKET, UNKNOWN;
---Purpose: Specifies the type of files.
--ABD Integration support of system fonts (using FTGL and FreeType)
enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic;
---Purpose: Specifies aspect of system font.
private enumeration WhoAmI is WDirectory, WDirectoryIterator,
WEnvironment, WFile, WFileNode, WFileIterator, WMailBox,
WPath, WProcess, WProtection, WSemaphore, WHost, WDisk,
WChronometer, WSharedMemory, WTimer, WPackage, WPrinter,
WEnvironmentIterator;
---Purpose: Allows great accuracy for error management.
-- This is private.
class Error;
---Purpose: Accurate management of OSD specific errors.
class Protection;
---Purpose: Gets and sets protection attributes of 'system , user ,
-- group, and world'.
class Path;
---Purpose: Manages independent system path translation.
deferred class FileNode;
---Purpose: A set of file/directory manipulation tools.
class Disk;
---Purpose: A set of disk oriented tools.
class File;
---Purpose: A set of file oriented tools.
class FileIterator;
---Purpose: Searches for child files in current directory.
class Directory;
---Purpose: A set of directory oriented tools
class DirectoryIterator;
---Purpose: Searches sub-directories in current directory.
class Chronometer;
---Purpose: Measures time elapsed for performance program tests.
-- Measures CPU time consumed by a method call.
class Timer;
---Purpose: Measures the effective time elapsed for a method call.
class Printer;
---Purpose: Selects a printer (used by File).
class Host;
---Purpose: Carries information about a host.
-- System version ,host name, nodename ...
class Environment;
---Purpose: Manages environment variables.
class EnvironmentIterator;
---Purpose: Get all environment variables.
class Process;
---Purpose: Process specific oriented tools
class SharedMemory;
---Purpose: Manages shared memory.
class Semaphore;
---Purpose: Manages semaphores.
-- class Mutex is alias Mutex from Standard;
---Purpose: Mutex object to synchronize threads within one process
class MailBox;
---Purpose: Manages asynchronous mail boxes.
class SharedLibrary;
---Purpose: Provides tools to load a shared library
-- and retrieve the address of an entry point.
imported PThread;
imported ThreadFunction;
class Thread;
---Purpose: A tool to manage threads
--ABD Integration support of system fonts (using FTGL and FreeType)
imported NListOfSystemFont;
class SystemFont;
class FontMgr;
class Real2String;
---Purpose: Convertion of CString to Real and reciprocally
class Localizer;
---Purpose: Manages locale.
-----------------------------------------------
-- UNIX specific exceptions and enumeration --
-----------------------------------------------
exception Signal inherits Failure from Standard;
exception SIGHUP inherits Signal;
exception SIGINT inherits Signal;
exception SIGQUIT inherits Signal;
exception SIGILL inherits Signal;
exception SIGKILL inherits Signal;
exception SIGBUS inherits Signal;
exception SIGSEGV inherits Signal;
exception SIGSYS inherits Signal;
enumeration Signals is
---purpose:
-- The "posix" signals.
--
S_SIGHUP, -- "hangup."
S_SIGINT, -- "interrupt."
S_SIGQUIT, -- "quit."
S_SIGILL, -- "illegal instruction."
S_SIGKILL, -- "kill."
S_SIGBUS, -- "bus error."
S_SIGSEGV, -- "segmentation violation."
S_SIGSYS, -- "bad argument to system call."
S_SIGFPE, -- "floating point exception."
S_FPE_FLTDIV_TRAP, -- "floating/decimal divide by zero."
S_FPE_INTDIV_TRAP, -- "integer divide by zero."
S_FPE_FLTOVF_TRAP, -- "floating overflow."
S_FPE_INTOVF_TRAP, -- "integer overflow."
S_FPE_FLTUND_TRAP, -- "floating underflow."
S_FPE_FLTINEX_TRAP -- "floating inexact result."
end Signals;
----------------------------------------
-- Exceptions ( Windows NT specific ) --
----------------------------------------
exception Exception inherits Failure from Standard;
exception Exception_ACCESS_VIOLATION inherits Exception;
exception Exception_ARRAY_BOUNDS_EXCEEDED inherits Exception;
exception Exception_FLT_DENORMAL_OPERAND inherits Exception;
exception Exception_FLT_DIVIDE_BY_ZERO inherits Exception;
exception Exception_FLT_INEXACT_RESULT inherits Exception;
exception Exception_FLT_INVALID_OPERATION inherits Exception;
exception Exception_FLT_OVERFLOW inherits Exception;
exception Exception_FLT_STACK_CHECK inherits Exception;
exception Exception_FLT_UNDERFLOW inherits Exception;
exception Exception_ILLEGAL_INSTRUCTION inherits Exception;
exception Exception_IN_PAGE_ERROR inherits Exception;
exception Exception_INT_DIVIDE_BY_ZERO inherits Exception;
exception Exception_INT_OVERFLOW inherits Exception;
exception Exception_INVALID_DISPOSITION inherits Exception;
exception Exception_NONCONTINUABLE_EXCEPTION inherits Exception;
exception Exception_PRIV_INSTRUCTION inherits Exception;
exception Exception_STACK_OVERFLOW inherits Exception;
exception Exception_STATUS_NO_MEMORY inherits Exception; -- generating by 'HeapAlloc'
exception Exception_CTRL_BREAK inherits Exception; -- generating by 'Ctrl-C' keystroke
----------------------------------------------
-- Handler and SegvHandler (UNIX specific ) --
----------------------------------------------
--
-- Handler(aSignal: Signals; aCode: Signals)
--
Handler(aSignal: Signals; aSigInfo: Address; aContext: Address)
---Purpose:
-- 1) Raise a exception when aSignal is a floating point signal.
-- aSignal is SIGFPE.
-- aCode is
-- (FPE: Floating Point Exception)
-- (FLT: FLoaTing operation.)
-- (INT: INTeger operation.)
-- (DIV: DIVided by zero.)
-- (OVF: OVerFlow.)
-- (INEX: INEXact operation.)
--
-- FPE_FLTDIV_TRAP (the exception "DivideByZero" is raised.)
-- FPE_INTDIV_TRAP (the exception "DivideByZero" is raised.)
--
-- FPE_FLTOVF_TRAP (the exception "Overflow" is raised.)
-- FPE_INTOVF_TRAP (the exception "Overflow" is raised.)
--
-- FPE_FLTINEX_TRAP (the exception "NumericError" is raised.)
--
-- 2) Display the signal name, and call "exit" with signal number for
-- a "Hardware" signal.
--
raises
DivideByZero,
Overflow,
Underflow,
SIGHUP,
SIGINT,
SIGQUIT,
SIGILL,
SIGKILL,
SIGBUS,
SIGSEGV,
SIGSYS
is private;
SegvHandler(aSignal: Signals; aSigInfo: Address; aContext: Address)
---Purpose:
-- Handle access to null object and segmentation violation
--
raises
NullObject,
SIGSEGV
is private;
---------------------------------------
-- WntHandler (Windows NT specific ) --
---------------------------------------
WntHandler ( exceptionInfo : Address from Standard )
returns Integer from Standard
raises DivideByZero,
Overflow,
Underflow,
Exception_ACCESS_VIOLATION,
Exception_ARRAY_BOUNDS_EXCEEDED,
Exception_FLT_DENORMAL_OPERAND,
Exception_FLT_DIVIDE_BY_ZERO,
Exception_FLT_INEXACT_RESULT,
Exception_FLT_INVALID_OPERATION,
Exception_FLT_OVERFLOW,
Exception_FLT_STACK_CHECK,
Exception_FLT_UNDERFLOW,
Exception_ILLEGAL_INSTRUCTION,
Exception_IN_PAGE_ERROR,
Exception_INVALID_DISPOSITION,
Exception_NONCONTINUABLE_EXCEPTION,
Exception_PRIV_INSTRUCTION,
Exception_STACK_OVERFLOW,
Exception_STATUS_NO_MEMORY
is private;
---Purpose:
-- 1) Raises an exception if the exception due to floating point errors.
-- Flosting point errors:
-- EXCEPTION_FLT_DENORMAL_OPERAND
-- EXCEPTION_FLT_DIVIDE_BY_ZERO
-- EXCEPTION_FLT_INEXACT_RESULT
-- EXCEPTION_FLT_INVALID_OPERATION
-- EXCEPTOPN_FLT_OVERFLOW
-- EXCEPTION_FLT_STACK_CHECK
-- EXCEPTION_FLT_UNDERFLOW
-- 2) Displays a message box 'Continue' - 'Debugger' - 'Stop' if the environment
-- variable 'CSF_EXCEPTION_PROMPT' is set and takes appropriate action.
-- Raises an exception otherwise.
SetSignal(aFloatingSignal: Boolean = Standard_True);
---Purpose:
-- 1) Arms some floating point signals, and sets a "Handler" for them.
-- 2) Sets a "Handler" for the "Hardware" signals.
-- For Win32 users: under VC++ you can control which method of handling
-- exceptions is used by means of UseSETranslator method before calling
-- SetSignal
--
-- Warning:
-- Some "Data Base Managers" use their own "Handler" for the signals
-- such as "SIGSEGV". So if a "Handler" is set for a signal it will
-- not be replaced by Standard "Handler". It is managed by OBJS
-- preprocessor definition.
--
---Level: Internal
AvailableMemory returns Integer from Standard;
---Purpose: Returns available memory in Kilobytes.
---Level: Advanced
SecSleep(aDelay: Integer from Standard);
---Purpose: Commands the process to sleep for a number of seconds.
---Level: Public
MilliSecSleep(aDelay: Integer from Standard);
---Purpose: Commands the process to sleep for a number of milliseconds
---Level: Public
RealToCString(aReal: Real; aString:out PCharacter)
returns Boolean ;
---Purpose:
-- 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
---Level: Public
CStringToReal(aString: CString; aReal: out Real) returns Boolean ;
---Purpose:
-- Converts aCstring representing a real with a period as
-- decimal point, no thousand separator and no grouping of digits
-- into aReal .
-- The conversion is independant from the current locale.
---Level: Public
IsDivisible(aDividend, aDivisor: Real from Standard)
returns Boolean from Standard;
---Purpose: Tests if the quotient theDividend/theDivisor
-- does not overflow
---Level: Public
GetExponent(aReal: Real from Standard)
returns Integer from Standard;
---Purpose: Returns the exponent in base 2 of a floating-point number.
---Level: Public
GetMantissa(aReal: Real from Standard)
returns Real from Standard;
---Purpose: Returns the mantissa of a floating-point number.
---Level: Public
-------------------------
-- Windows NT specific --
-------------------------
ControlBreak raises Exception_CTRL_BREAK;
---Purpose: 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.
UseSETranslator(useSE : Boolean);
---Purpose: Defines whether SetSignal must use _se_translator_function or
-- SetUnhandledExceptionFilter and signal to catch system
-- exceptions. The default behaviour is to use SE translator.
-- Warning: Using SE translator method SetSignal should be called for each
-- new created thread, while using the alternative method
-- the exception handler is established once for the whole
-- process and all its threads.
-- This function takes effect only under VC++ compiler.
UseSETranslator returns Boolean;
---Purpose: Returns the current value of the flag set by above method.
end OSD;
|