1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . S T O R A G E _ E L E M E N T S --
9 -- Copyright (C) 2002-2013, Free Software Foundation, Inc. --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the implementation dependent sections of this file. --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
26 -- You should have received a copy of the GNU General Public License and --
27 -- a copy of the GCC Runtime Library Exception along with this program; --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
29 -- <http://www.gnu.org/licenses/>. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 -- Warning: declarations in this package are ambiguous with respect to the
37 -- extra declarations that can be introduced into System using Extend_System.
38 -- It is a good idea to avoid use clauses for this package.
40 package System
.Storage_Elements
is
42 -- Note that we take advantage of the implementation permission to make
43 -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada 2005,
44 -- this is Pure in any case (AI-362).
46 -- We also add the pragma Pure_Function to the operations in this package,
47 -- because otherwise functions with parameters derived from Address are
48 -- treated as non-pure by the back-end (see exp_ch6.adb). This is because
49 -- in many cases such a parameter is used to hide read/out access to
50 -- objects, and it would be unsafe to treat such functions as pure.
52 type Storage_Offset
is range
53 -(2 ** (Integer'(Standard'Address_Size) - 1)) ..
54 +(2 ** (Integer'(Standard
'Address_Size) - 1)) - Long_Long_Integer'(1);
55 -- Note: the reason for the Long_Long_Integer qualification here is to
56 -- avoid a bogus ambiguity when this unit is analyzed in an rtsfind
57 -- context. It may be possible to remove this in the future, but it is
58 -- certainly harmless in any case ???
60 subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last;
62 type Storage_Element is mod 2 ** Storage_Unit;
63 for Storage_Element'Size use Storage_Unit;
65 pragma Universal_Aliasing (Storage_Element);
66 -- This type is used by the expander to implement aggregate copy
69 array (Storage_Offset range <>) of aliased Storage_Element;
70 for Storage_Array'Component_Size use Storage_Unit;
74 function "+" (Left : Address; Right : Storage_Offset) return Address;
75 pragma Convention (Intrinsic, "+");
76 pragma Inline_Always ("+");
77 pragma Pure_Function ("+");
79 function "+" (Left : Storage_Offset; Right : Address) return Address;
80 pragma Convention (Intrinsic, "+");
81 pragma Inline_Always ("+");
82 pragma Pure_Function ("+");
84 function "-" (Left : Address; Right : Storage_Offset) return Address;
85 pragma Convention (Intrinsic, "-");
86 pragma Inline_Always ("-");
87 pragma Pure_Function ("-");
89 function "-" (Left, Right : Address) return Storage_Offset;
90 pragma Convention (Intrinsic, "-");
91 pragma Inline_Always ("-");
92 pragma Pure_Function ("-");
96 Right : Storage_Offset) return Storage_Offset;
97 pragma Convention (Intrinsic, "mod");
98 pragma Inline_Always ("mod");
99 pragma Pure_Function ("mod");
101 -- Conversion to/from integers
103 type Integer_Address is mod Memory_Size;
105 function To_Address (Value : Integer_Address) return Address;
106 pragma Convention (Intrinsic, To_Address);
107 pragma Inline_Always (To_Address);
108 pragma Pure_Function (To_Address);
110 function To_Integer (Value : Address) return Integer_Address;
111 pragma Convention (Intrinsic, To_Integer);
112 pragma Inline_Always (To_Integer);
113 pragma Pure_Function (To_Integer);
115 end System.Storage_Elements;