File : s-memory-zfp.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 package System.Memory is
40 pragma Elaborate_Body;
41
42 type size_t is mod 2 ** Standard'Address_Size;
43 -- Note: the reason we redefine this here instead of using the
44 -- definition in Interfaces.C is that we do not want to drag in
45 -- all of Interfaces.C just because System.Memory is used.
46
47 function Alloc (Size : size_t) return System.Address;
48 -- This is the low level allocation routine. Given a size in storage
49 -- units, it returns the address of a maximally aligned block of
50 -- memory.
51 --
52 -- A first check is performed to discard memory allocations that are
53 -- obviously too big, preventing problems of memory wraparound. If Size is
54 -- greater than the maximum number of storage elements (taking into account
55 -- the maximum alignment) in the machine, then a Storage_Error exception is
56 -- raised before trying to perform the memory allocation.
57 --
58 -- If Size is set to zero on entry, then a minimal (but non-zero)
59 -- size block is allocated.
60 --
61 -- If there is not enough free memory on the heap for the requested
62 -- allocation then a Storage_Error exception is raised and the heap remains
63 -- unchanged.
64 --
65 -- Note: this is roughly equivalent to the standard C malloc call
66 -- with the additional semantics as described above.
67
68 private
69 -- The following names are used from the generated compiler code
70
71 pragma Export (C, Alloc, "__gnat_malloc");
72
73 end System.Memory;