File : s-secsta-static.ads


   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                --
   6 --                                                                          --
   7 --                                 S p e c                                  --
   8 --                                                                          --
   9 --          Copyright (C) 1992-2012, 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 --  This is the static version of this package spec, for use with runtimes
  33 --  that don't use dynamic allocation (such as zfp or minimal)
  34 
  35 with System.Storage_Elements;
  36 
  37 package System.Secondary_Stack is
  38 
  39    package SSE renames System.Storage_Elements;
  40 
  41    Default_Secondary_Stack_Size : constant := 10 * 1024;
  42    --  Default size of a secondary stack
  43 
  44    procedure SS_Init
  45      (Stk  : System.Address;
  46       Size : Natural := Default_Secondary_Stack_Size);
  47    --  Initialize the secondary stack with a main stack of the given Size.
  48    --
  49    --  Stk is an "in" parameter that is already pointing to a memory area of
  50    --  size Size.
  51    --
  52    --  The secondary stack is fixed, and any attempt to allocate more than the
  53    --  initial size will result in a Storage_Error being raised.
  54 
  55    procedure SS_Allocate
  56      (Address      : out System.Address;
  57       Storage_Size : SSE.Storage_Count);
  58    --  Allocate enough space for a 'Storage_Size' bytes object with Maximum
  59    --  alignment. The address of the allocated space is returned in 'Address'
  60 
  61    type Mark_Id is private;
  62    --  Type used to mark the stack
  63 
  64    function SS_Mark return Mark_Id;
  65    --  Return the Mark corresponding to the current state of the stack
  66 
  67    procedure SS_Release (M : Mark_Id);
  68    --  Restore the state of the stack corresponding to the mark M. If an
  69    --  additional chunk have been allocated, it will never be freed during a
  70 
  71 private
  72 
  73    SS_Pool : Integer;
  74    --  Unused entity that is just present to ease the sharing of the pool
  75    --  mechanism for specific allocation/deallocation in the compiler
  76 
  77    type Mark_Address is new SSE.Integer_Address;
  78 
  79    type Mark_Id is record
  80       Mark_Addr : Mark_Address;
  81       Unused    : System.Address;
  82    end record;
  83    --  A Mark_Id value contains the address of the mark point in the secondary
  84    --  stack. This type is defined as two addresses for compatibility with the
  85    --  the standard version of the secondary stack, even though the second
  86    --  address is unused in this version. The GNAAMP back end generates calls
  87    --  to SS_Mark and SS_Release in certain cases and the calling sequences
  88    --  must be compatible.
  89 
  90 end System.Secondary_Stack;