Debian Codegraph @

gcc/ada/libgnat/s-stchop.ads

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . S T A C K _ C H E C K I N G . O P E R A T I O N S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1999-2025, Free Software Foundation, Inc. --
10 -- --
11 -- GNARL 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 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This package provides a implementation of stack checking operations using
33 -- comparison with stack base and limit.
34
35 pragma Restrictions (No_Elaboration_Code);
36 -- We want to guarantee the absence of elaboration code because the binder
37 -- does not handle references to this package.
38
39 with System.Storage_Elements;
40
41 package System.Stack_Checking.Operations is
42 pragma Preelaborate;
43
44 procedure Update_Stack_Cache (Stack : Stack_Access);
45 -- Set the stack cache for the current task. Note that this is only for
46 -- optimization purposes, nothing can be assumed about the contents of the
47 -- cache at any time, see Set_Stack_Info.
48 --
49 -- The stack cache should contain the bounds of the current task. But
50 -- because the RTS is not aware of task switches, the stack cache may be
51 -- incorrect. So when the stack pointer is not within the bounds of the
52 -- stack cache, Stack_Check first update the cache (which is a costly
53 -- operation hence the need of a cache).
54
55 procedure Invalidate_Stack_Cache (Any_Stack : Stack_Access);
56 -- Invalidate cache entries for the task T that owns Any_Stack. This causes
57 -- the Set_Stack_Info function to be called during the next stack check
58 -- done by T. This can be used to interrupt task T asynchronously.
59 -- Stack_Check should be called in loops for this to work reliably.
60
61 function Stack_Check (Stack_Address : System.Address) return Stack_Access;
62 -- This version of Stack_Check should not be inlined
63
64 procedure Notify_Stack_Attributes
65 (Initial_SP : System.Address;
66 Size : System.Storage_Elements.Storage_Offset);
67 -- Register Initial_SP as the initial stack pointer value for the current
68 -- task when it starts and Size as the associated stack area size. This
69 -- should be called once, after the soft-links have been initialized and
70 -- prior to the first "Stack_Check" call.
71
72 private
73 Cache : aliased Stack_Access := Null_Stack;
74
75 pragma Export (C, Cache, "__gnat_stack_cache");
76 pragma Export (C, Stack_Check, "__gnat_stack_check");
77
78 end System.Stack_Checking.Operations;