annotate gcc/ada/libgnat/s-memory.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . M E M O R Y --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2001-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides the low level memory allocation/deallocation
kono
parents:
diff changeset
33 -- mechanisms used by GNAT.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 -- To provide an alternate implementation, simply recompile the modified
kono
parents:
diff changeset
36 -- body of this package with gnatmake -u -a -g s-memory.adb and make sure
kono
parents:
diff changeset
37 -- that the ali and object files for this unit are found in the object
kono
parents:
diff changeset
38 -- search path.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- This unit may be used directly from an application program by providing
kono
parents:
diff changeset
41 -- an appropriate WITH, and the interface can be expected to remain stable.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 pragma Compiler_Unit_Warning;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 package System.Memory is
kono
parents:
diff changeset
46 pragma Elaborate_Body;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 type size_t is mod 2 ** Standard'Address_Size;
kono
parents:
diff changeset
49 -- Note: the reason we redefine this here instead of using the
kono
parents:
diff changeset
50 -- definition in Interfaces.C is that we do not want to drag in
kono
parents:
diff changeset
51 -- all of Interfaces.C just because System.Memory is used.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 function Alloc (Size : size_t) return System.Address;
kono
parents:
diff changeset
54 -- This is the low level allocation routine. Given a size in storage
kono
parents:
diff changeset
55 -- units, it returns the address of a maximally aligned block of
kono
parents:
diff changeset
56 -- memory. The implementation of this routine is guaranteed to be
kono
parents:
diff changeset
57 -- task safe, and also aborts are deferred if necessary.
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 -- If Size is set to size_t'Last on entry, then a Storage_Error
kono
parents:
diff changeset
60 -- exception is raised with a message "object too large".
kono
parents:
diff changeset
61 --
kono
parents:
diff changeset
62 -- If Size is set to zero on entry, then a minimal (but non-zero)
kono
parents:
diff changeset
63 -- size block is allocated.
kono
parents:
diff changeset
64 --
kono
parents:
diff changeset
65 -- Note: this is roughly equivalent to the standard C malloc call
kono
parents:
diff changeset
66 -- with the additional semantics as described above.
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Free (Ptr : System.Address);
kono
parents:
diff changeset
69 -- This is the low level free routine. It frees a block previously
kono
parents:
diff changeset
70 -- allocated with a call to Alloc. As in the case of Alloc, this
kono
parents:
diff changeset
71 -- call is guaranteed task safe, and aborts are deferred.
kono
parents:
diff changeset
72 --
kono
parents:
diff changeset
73 -- Note: this is roughly equivalent to the standard C free call
kono
parents:
diff changeset
74 -- with the additional semantics as described above.
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Realloc
kono
parents:
diff changeset
77 (Ptr : System.Address;
kono
parents:
diff changeset
78 Size : size_t) return System.Address;
kono
parents:
diff changeset
79 -- This is the low level reallocation routine. It takes an existing
kono
parents:
diff changeset
80 -- block address returned by a previous call to Alloc or Realloc,
kono
parents:
diff changeset
81 -- and reallocates the block. The size can either be increased or
kono
parents:
diff changeset
82 -- decreased. If possible the reallocation is done in place, so that
kono
parents:
diff changeset
83 -- the returned result is the same as the value of Ptr on entry.
kono
parents:
diff changeset
84 -- However, it may be necessary to relocate the block to another
kono
parents:
diff changeset
85 -- address, in which case the information is copied to the new
kono
parents:
diff changeset
86 -- block, and the old block is freed. The implementation of this
kono
parents:
diff changeset
87 -- routine is guaranteed to be task safe, and also aborts are
kono
parents:
diff changeset
88 -- deferred as necessary.
kono
parents:
diff changeset
89 --
kono
parents:
diff changeset
90 -- If Size is set to size_t'Last on entry, then a Storage_Error
kono
parents:
diff changeset
91 -- exception is raised with a message "object too large".
kono
parents:
diff changeset
92 --
kono
parents:
diff changeset
93 -- If Size is set to zero on entry, then a minimal (but non-zero)
kono
parents:
diff changeset
94 -- size block is allocated.
kono
parents:
diff changeset
95 --
kono
parents:
diff changeset
96 -- Note: this is roughly equivalent to the standard C realloc call
kono
parents:
diff changeset
97 -- with the additional semantics as described above.
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 private
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 -- The following names are used from the generated compiler code
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 pragma Export (C, Alloc, "__gnat_malloc");
kono
parents:
diff changeset
104 pragma Export (C, Free, "__gnat_free");
kono
parents:
diff changeset
105 pragma Export (C, Realloc, "__gnat_realloc");
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 end System.Memory;