OSDN Git Service

Delete all lines containing "$Revision:".
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-pooglo.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                   S Y S T E M . P O O L _ G L O B A L                    --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 with System.Storage_Pools;    use System.Storage_Pools;
36 with System.Storage_Elements;
37 with System.Memory;
38
39 package body System.Pool_Global is
40
41    package SSE renames System.Storage_Elements;
42
43    --------------
44    -- Allocate --
45    --------------
46
47    procedure Allocate
48      (Pool         : in out Unbounded_No_Reclaim_Pool;
49       Address      : out System.Address;
50       Storage_Size : SSE.Storage_Count;
51       Alignment    : SSE.Storage_Count)
52    is
53       pragma Warnings (Off, Pool);
54       pragma Warnings (Off, Alignment);
55
56       Allocated : System.Address;
57
58    begin
59       Allocated := Memory.Alloc (Memory.size_t (Storage_Size));
60
61       --  The call to Alloc returns an address whose alignment is compatible
62       --  with the worst case alignment requirement for the machine; thus the
63       --  Alignment argument can be safely ignored.
64
65       if Allocated = Null_Address then
66          raise Storage_Error;
67       else
68          Address := Allocated;
69       end if;
70    end Allocate;
71
72    ----------------
73    -- Deallocate --
74    ----------------
75
76    procedure Deallocate
77      (Pool         : in out Unbounded_No_Reclaim_Pool;
78       Address      : System.Address;
79       Storage_Size : SSE.Storage_Count;
80       Alignment    : SSE.Storage_Count)
81    is
82       pragma Warnings (Off, Pool);
83       pragma Warnings (Off, Storage_Size);
84       pragma Warnings (Off, Alignment);
85
86    begin
87       Memory.Free (Address);
88    end Deallocate;
89
90    ------------------
91    -- Storage_Size --
92    ------------------
93
94    function Storage_Size
95      (Pool  : Unbounded_No_Reclaim_Pool)
96       return  SSE.Storage_Count
97    is
98       pragma Warnings (Off, Pool);
99
100    begin
101       --  Intuitively, should return System.Memory_Size. But on Sun/Alsys,
102       --  System.Memory_Size > System.Max_Int, which means all you can do with
103       --  it is raise CONSTRAINT_ERROR...
104
105       return SSE.Storage_Count'Last;
106    end Storage_Size;
107
108 end System.Pool_Global;