File : s-memory-cert.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . M E M O R Y --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2014, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- --
19 -- --
20 -- --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This is a simplified version of this package, for use with a configurable
33 -- run-time library that does not provide Ada tasking. It does not provide
34 -- any deallocation routine.
35
36 -- This package provides the low level memory allocation/deallocation
37 -- mechanisms used by GNAT.
38
39 -- To provide an alternate implementation, simply recompile the modified
40 -- body of this package with gnatmake -u -a -g s-memory.adb and make sure
41 -- that the ali and object files for this unit are found in the object
42 -- search path.
43
44 -- This unit may be used directly from an application program by providing
45 -- an appropriate WITH, and the interface can be expected to remain stable.
46
47 package System.Memory is
48 pragma Elaborate_Body;
49
50 type size_t is mod 2 ** Standard'Address_Size;
51 -- Note: the reason we redefine this here instead of using the
52 -- definition in Interfaces.C is that we do not want to drag in
53 -- all of Interfaces.C just because System.Memory is used.
54
55 function Alloc (Size : size_t) return System.Address;
56 -- This is the low level allocation routine. Given a size in storage
57 -- units, it returns the address of a maximally aligned block of
58 -- memory.
59 --
60 -- If size_t is set to size_t'Last on entry, then a Storage_Error
61 -- exception is raised with a message "object too large".
62 --
63 -- If size_t is set to zero on entry, then a minimal (but non-zero)
64 -- size block is allocated.
65 --
66 -- Note: this is roughly equivalent to the standard C malloc call
67 -- with the additional semantics as described above.
68
69 procedure Free (Ptr : System.Address);
70 -- Memory deallocation is not allowed in certifiable runtimes, so this
71 -- routine raises Program_Error.
72
73 private
74 -- The following names are used from the generated compiler code
75
76 pragma Export (C, Alloc, "__gnat_malloc");
77 pragma Export (C, Free, "__gnat_free");
78
79 end System.Memory;