File : s-sssita-xi.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . S E C O N D A R Y _ S T A C K . S I N G L E _ T A S K --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2005-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 -- --
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 pragma Restrictions (No_Elaboration_Code);
33 -- We want to guarantee the absence of elaboration code because the
34 -- binder does not handle references to this package.
35
36 with System.Storage_Elements;
37
38 package body System.Secondary_Stack.Single_Task is
39
40 ----------------
41 -- Local Data --
42 ----------------
43
44 Initialized : Boolean := False;
45 -- Boolean flag that indicates whether the memory area to be used as a
46 -- secondary stack has already been initialized.
47
48 Secondary_Stack : aliased Storage_Elements.Storage_Array
49 (1 .. Storage_Elements.Storage_Offset (Default_Secondary_Stack_Size));
50 for Secondary_Stack'Alignment use Standard'Maximum_Alignment;
51 -- The secondary stack
52
53 -------------------
54 -- Get_Sec_Stack --
55 -------------------
56
57 function Get_Sec_Stack return Address is
58 begin
59 if not Initialized then
60 -- Initialize the secondary stack
61
62 SS_Init (Secondary_Stack'Address, Default_Secondary_Stack_Size);
63
64 Initialized := True;
65 end if;
66
67 return Secondary_Stack'Address;
68 end Get_Sec_Stack;
69
70 end System.Secondary_Stack.Single_Task;