OSDN Git Service

PR c++/60046
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-memory-vms_64.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-2010, 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 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
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 package provides the low level memory allocation/deallocation
33 --  mechanisms used by GNAT for VMS 64 bit.
34
35 --  To provide an alternate implementation, simply recompile the modified
36 --  body of this package with gnatmake -u -a -g s-memory.adb and make sure
37 --  that the ali and object files for this unit are found in the object
38 --  search path.
39
40 --  This unit may be used directly from an application program by providing
41 --  an appropriate WITH, and the interface can be expected to remain stable.
42
43 pragma Compiler_Unit;
44
45 package System.Memory is
46    pragma Elaborate_Body;
47
48    type size_t is mod 2 ** Standard'Address_Size;
49    --  Note: the reason we redefine this here instead of using the
50    --  definition in Interfaces.C is that we do not want to drag in
51    --  all of Interfaces.C just because System.Memory is used.
52
53    function Alloc (Size : size_t) return System.Address;
54    --  This is the low level allocation routine. Given a size in storage
55    --  units, it returns the address of a maximally aligned block of
56    --  memory. The implementation of this routine is guaranteed to be
57    --  task safe, and also aborts are deferred if necessary.
58    --
59    --  If size_t is set to size_t'Last on entry, then a Storage_Error
60    --  exception is raised with a message "object too large".
61    --
62    --  If size_t is set to zero on entry, then a minimal (but non-zero)
63    --  size block is allocated.
64    --
65    --  Note: this is roughly equivalent to the standard C malloc call
66    --  with the additional semantics as described above.
67
68    function Alloc32 (Size : size_t) return System.Address;
69    --  Equivalent to Alloc except on VMS 64 bit where it invokes
70    --  32 bit malloc.
71
72    procedure Free (Ptr : System.Address);
73    --  This is the low level free routine. It frees a block previously
74    --  allocated with a call to Alloc. As in the case of Alloc, this
75    --  call is guaranteed task safe, and aborts are deferred.
76    --
77    --  Note: this is roughly equivalent to the standard C free call
78    --  with the additional semantics as described above.
79
80    function Realloc
81      (Ptr  : System.Address;
82       Size : size_t) return System.Address;
83    --  This is the low level reallocation routine. It takes an existing
84    --  block address returned by a previous call to Alloc or Realloc,
85    --  and reallocates the block. The size can either be increased or
86    --  decreased. If possible the reallocation is done in place, so that
87    --  the returned result is the same as the value of Ptr on entry.
88    --  However, it may be necessary to relocate the block to another
89    --  address, in which case the information is copied to the new
90    --  block, and the old block is freed. The implementation of this
91    --  routine is guaranteed to be task safe, and also aborts are
92    --  deferred as necessary.
93    --
94    --  If size_t is set to size_t'Last on entry, then a Storage_Error
95    --  exception is raised with a message "object too large".
96    --
97    --  If size_t is set to zero on entry, then a minimal (but non-zero)
98    --  size block is allocated.
99    --
100    --  Note: this is roughly equivalent to the standard C realloc call
101    --  with the additional semantics as described above.
102
103    function Realloc32
104      (Ptr  : System.Address;
105       Size : size_t) return System.Address;
106    --  Equivalent to Realloc except on VMS 64 bit where it invokes
107    --  32 bit realloc.
108
109 private
110
111    --  The following names are used from the generated compiler code
112
113    pragma Export (C, Alloc,   "__gnat_malloc");
114    pragma Export (C, Alloc32, "__gnat_malloc32");
115    pragma Export (C, Free,    "__gnat_free");
116    pragma Export (C, Realloc, "__gnat_realloc");
117    pragma Export (C, Realloc32, "__gnat_realloc32");
118
119    function C_malloc32 (Size : size_t) return System.Address;
120    pragma Import (C, C_malloc32, "_malloc32");
121    --  An alias for malloc for allocating 32bit memory on 64bit VMS
122
123    function C_realloc32
124      (Ptr  : System.Address;
125       Size : size_t) return System.Address;
126    pragma Import (C, C_realloc32, "_realloc32");
127    --  An alias for realloc for allocating 32bit memory on 64bit VMS
128
129 end System.Memory;