]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/Storage.def
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / Storage.def
1 (* Library module defined by the International Standard
2 Information technology - programming languages
3 BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
4
5 Copyright ISO/IEC (International Organization for Standardization
6 and International Electrotechnical Commission) 1996-2021.
7
8 It may be freely copied for the purpose of implementation (see page
9 707 of the Information technology - Programming languages Part 1:
10 Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
11
12 DEFINITION MODULE Storage;
13
14 (* Facilities for dynamically allocating and deallocating storage *)
15
16 IMPORT SYSTEM;
17
18 PROCEDURE ALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
19 (* Allocates storage for a variable of size amount and assigns
20 the address of this variable to addr. If there is insufficient
21 unallocated storage to do this, the value NIL is assigned to addr.
22 *)
23
24 PROCEDURE DEALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
25 (* Deallocates amount locations allocated by ALLOCATE for
26 the storage of the variable addressed by addr and assigns
27 the value NIL to addr.
28 *)
29
30 PROCEDURE REALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
31 (* Attempts to reallocate, amount of storage. Effectively it
32 calls ALLOCATE, copies the amount of data pointed to by
33 addr into the new space and DEALLOCATES the addr.
34 This procedure is a GNU extension.
35 *)
36
37 TYPE
38 StorageExceptions = (
39 nilDeallocation, (* first argument to DEALLOCATE is NIL *)
40 pointerToUnallocatedStorage, (* storage to deallocate not allocated by ALLOCATE *)
41 wrongStorageToUnallocate (* amount to deallocate is not amount allocated *)
42 );
43
44 PROCEDURE IsStorageException (): BOOLEAN;
45 (* Returns TRUE if the current coroutine is in the exceptional
46 execution state because of the raising of an exception from
47 StorageExceptions; otherwise returns FALSE.
48 *)
49
50 PROCEDURE StorageException (): StorageExceptions;
51 (* If the current coroutine is in the exceptional execution
52 state because of the raising of an exception from
53 StorageExceptions, returns the corresponding
54 enumeration value, and otherwise raises an exception.
55 *)
56
57 END Storage.