annotate gcc/ada/libgnat/s-stchop__vxworks.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
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 --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1999-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNARL is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNARL was developed by the GNARL team at Florida State University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This is the verson for VxWorks 5, VxWorks 6 Cert and VxWorks MILS
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 -- This file should be kept synchronized with the general implementation
kono
parents:
diff changeset
35 -- provided by s-stchop.adb.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 pragma Restrictions (No_Elaboration_Code);
kono
parents:
diff changeset
38 -- We want to guarantee the absence of elaboration code because the
kono
parents:
diff changeset
39 -- binder does not handle references to this package.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with System.Storage_Elements; use System.Storage_Elements;
kono
parents:
diff changeset
42 with System.Parameters; use System.Parameters;
kono
parents:
diff changeset
43 with Interfaces.C;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 package body System.Stack_Checking.Operations is
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 -- In order to have stack checking working appropriately on VxWorks we need
kono
parents:
diff changeset
48 -- to extract the stack size information from the VxWorks kernel itself.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 -- For VxWorks 5 & 6 the library for showing task-related information
kono
parents:
diff changeset
51 -- needs to be linked into the VxWorks system, when using stack checking.
kono
parents:
diff changeset
52 -- The taskShow library can be linked into the VxWorks system by either:
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 -- * defining INCLUDE_SHOW_ROUTINES in config.h when using
kono
parents:
diff changeset
55 -- configuration header files, or
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 -- * selecting INCLUDE_TASK_SHOW when using the Tornado project
kono
parents:
diff changeset
58 -- facility.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- VxWorks MILS includes the necessary routine in taskLib, so nothing
kono
parents:
diff changeset
61 -- special needs to be done there.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Stack_Limit : Address;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 pragma Import (C, Stack_Limit, "__gnat_stack_limit");
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- Stack_Limit contains the limit of the stack. This variable is later made
kono
parents:
diff changeset
68 -- a task variable (by calling taskVarAdd) and then correctly set to the
kono
parents:
diff changeset
69 -- stack limit of the task. Before being so initialized its value must be
kono
parents:
diff changeset
70 -- valid so that any subprogram with stack checking enabled will run. We
kono
parents:
diff changeset
71 -- use extreme values according to the direction of the stack.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 type Set_Stack_Limit_Proc_Acc is access procedure;
kono
parents:
diff changeset
74 pragma Convention (C, Set_Stack_Limit_Proc_Acc);
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 Set_Stack_Limit_Hook : Set_Stack_Limit_Proc_Acc;
kono
parents:
diff changeset
77 pragma Import (C, Set_Stack_Limit_Hook, "__gnat_set_stack_limit_hook");
kono
parents:
diff changeset
78 -- Procedure to be called when a task is created to set stack
kono
parents:
diff changeset
79 -- limit.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure Set_Stack_Limit_For_Current_Task;
kono
parents:
diff changeset
82 pragma Convention (C, Set_Stack_Limit_For_Current_Task);
kono
parents:
diff changeset
83 -- Register Initial_SP as the initial stack pointer value for the current
kono
parents:
diff changeset
84 -- task when it starts and Size as the associated stack area size. This
kono
parents:
diff changeset
85 -- should be called once, after the soft-links have been initialized?
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 -----------------------------
kono
parents:
diff changeset
88 -- Initialize_Stack_Limit --
kono
parents:
diff changeset
89 -----------------------------
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 procedure Initialize_Stack_Limit is
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Set_Stack_Limit_For_Current_Task;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- Will be called by every created task
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 Set_Stack_Limit_Hook := Set_Stack_Limit_For_Current_Task'Access;
kono
parents:
diff changeset
99 end Initialize_Stack_Limit;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 --------------------------------------
kono
parents:
diff changeset
102 -- Set_Stack_Limit_For_Current_Task --
kono
parents:
diff changeset
103 --------------------------------------
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 procedure Set_Stack_Limit_For_Current_Task is
kono
parents:
diff changeset
106 type OS_Stack_Info is record
kono
parents:
diff changeset
107 Size : Interfaces.C.int;
kono
parents:
diff changeset
108 Base : System.Address;
kono
parents:
diff changeset
109 Limit : System.Address;
kono
parents:
diff changeset
110 end record;
kono
parents:
diff changeset
111 pragma Convention (C, OS_Stack_Info);
kono
parents:
diff changeset
112 -- Type representing the information that we want to extract from the
kono
parents:
diff changeset
113 -- underlying kernel.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 procedure Get_Stack_Info (Stack : not null access OS_Stack_Info);
kono
parents:
diff changeset
116 pragma Import (C, Get_Stack_Info, "__gnat_get_stack_info");
kono
parents:
diff changeset
117 -- Procedure that fills the stack information associated to the
kono
parents:
diff changeset
118 -- currently executing task.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 Stack_Info : aliased OS_Stack_Info;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 Limit : System.Address;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 -- Get stack bounds from VxWorks
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 Get_Stack_Info (Stack_Info'Access);
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 if Stack_Grows_Down then
kono
parents:
diff changeset
131 Limit :=
kono
parents:
diff changeset
132 Stack_Info.Base - Storage_Offset (Stack_Info.Size) +
kono
parents:
diff changeset
133 Storage_Offset'(12_000);
kono
parents:
diff changeset
134 else
kono
parents:
diff changeset
135 Limit :=
kono
parents:
diff changeset
136 Stack_Info.Base + Storage_Offset (Stack_Info.Size) -
kono
parents:
diff changeset
137 Storage_Offset'(12_000);
kono
parents:
diff changeset
138 end if;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 Stack_Limit := Limit;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 end Set_Stack_Limit_For_Current_Task;
kono
parents:
diff changeset
143 end System.Stack_Checking.Operations;