1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- S Y S T E M . T A S K I N G . T A S K _ A T T R I B U T E S --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1991-1994, Florida State University --
|
10 |
|
|
-- Copyright (C) 1995-2010, AdaCore --
|
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 3, 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. --
|
18 |
|
|
-- --
|
19 |
|
|
-- As a special exception under Section 7 of GPL version 3, you are granted --
|
20 |
|
|
-- additional permissions described in the GCC Runtime Library Exception, --
|
21 |
|
|
-- version 3.1, as published by the Free Software Foundation. --
|
22 |
|
|
-- --
|
23 |
|
|
-- You should have received a copy of the GNU General Public License and --
|
24 |
|
|
-- a copy of the GCC Runtime Library Exception along with this program; --
|
25 |
|
|
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
26 |
|
|
-- <http://www.gnu.org/licenses/>. --
|
27 |
|
|
-- --
|
28 |
|
|
-- GNARL was developed by the GNARL team at Florida State University. --
|
29 |
|
|
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
|
30 |
|
|
-- --
|
31 |
|
|
------------------------------------------------------------------------------
|
32 |
|
|
|
33 |
|
|
-- This package provides support for the body of Ada.Task_Attributes
|
34 |
|
|
|
35 |
|
|
with Ada.Finalization;
|
36 |
|
|
|
37 |
|
|
with System.Storage_Elements;
|
38 |
|
|
|
39 |
|
|
package System.Tasking.Task_Attributes is
|
40 |
|
|
|
41 |
|
|
type Attribute is new Integer;
|
42 |
|
|
-- A stand-in for the generic formal type of Ada.Task_Attributes
|
43 |
|
|
-- in the following declarations.
|
44 |
|
|
|
45 |
|
|
type Node;
|
46 |
|
|
type Access_Node is access all Node;
|
47 |
|
|
-- This needs comments ???
|
48 |
|
|
|
49 |
|
|
function To_Access_Node is new Ada.Unchecked_Conversion
|
50 |
|
|
(Access_Address, Access_Node);
|
51 |
|
|
-- Used to fetch pointer to indirect attribute list. Declaration is in
|
52 |
|
|
-- spec to avoid any problems with aliasing assumptions.
|
53 |
|
|
|
54 |
|
|
type Dummy_Wrapper;
|
55 |
|
|
type Access_Dummy_Wrapper is access all Dummy_Wrapper;
|
56 |
|
|
pragma No_Strict_Aliasing (Access_Dummy_Wrapper);
|
57 |
|
|
-- Needed to avoid possible incorrect aliasing situations from
|
58 |
|
|
-- instantiation of Unchecked_Conversion in body of Ada.Task_Attributes.
|
59 |
|
|
|
60 |
|
|
for Access_Dummy_Wrapper'Storage_Size use 0;
|
61 |
|
|
-- Access_Dummy_Wrapper is a stand-in for the generic type Wrapper defined
|
62 |
|
|
-- in Ada.Task_Attributes. The real objects allocated are always
|
63 |
|
|
-- of type Wrapper, no Dummy_Wrapper objects are ever created.
|
64 |
|
|
|
65 |
|
|
type Deallocator is access procedure (P : in out Access_Node);
|
66 |
|
|
-- Called to deallocate an Wrapper. P is a pointer to a Node within
|
67 |
|
|
|
68 |
|
|
type Instance;
|
69 |
|
|
|
70 |
|
|
type Access_Instance is access all Instance;
|
71 |
|
|
|
72 |
|
|
type Instance is new Ada.Finalization.Limited_Controlled with record
|
73 |
|
|
Deallocate : Deallocator;
|
74 |
|
|
Initial_Value : aliased System.Storage_Elements.Integer_Address;
|
75 |
|
|
|
76 |
|
|
Index : Direct_Index;
|
77 |
|
|
-- The index of the TCB location used by this instantiation, if it is
|
78 |
|
|
-- stored in the TCB, otherwise zero.
|
79 |
|
|
|
80 |
|
|
Next : Access_Instance;
|
81 |
|
|
-- Next instance in All_Attributes list
|
82 |
|
|
end record;
|
83 |
|
|
|
84 |
|
|
procedure Finalize (X : in out Instance);
|
85 |
|
|
|
86 |
|
|
type Node is record
|
87 |
|
|
Wrapper : Access_Dummy_Wrapper;
|
88 |
|
|
Instance : Access_Instance;
|
89 |
|
|
Next : Access_Node;
|
90 |
|
|
end record;
|
91 |
|
|
|
92 |
|
|
-- The following type is a stand-in for the actual wrapper type, which is
|
93 |
|
|
-- different for each instantiation of Ada.Task_Attributes.
|
94 |
|
|
|
95 |
|
|
type Dummy_Wrapper is record
|
96 |
|
|
Dummy_Node : aliased Node;
|
97 |
|
|
|
98 |
|
|
Value : aliased Attribute;
|
99 |
|
|
-- The generic formal type, may be controlled
|
100 |
|
|
end record;
|
101 |
|
|
|
102 |
|
|
for Dummy_Wrapper'Alignment use Standard'Maximum_Alignment;
|
103 |
|
|
-- A number of unchecked conversions involving Dummy_Wrapper_Access
|
104 |
|
|
-- sources are performed in other units (e.g. Ada.Task_Attributes).
|
105 |
|
|
-- Ensure that the designated object is always strictly enough aligned.
|
106 |
|
|
|
107 |
|
|
In_Use : Direct_Index_Vector := 0;
|
108 |
|
|
-- Set True for direct indexes that are already used (True??? type???)
|
109 |
|
|
|
110 |
|
|
All_Attributes : Access_Instance;
|
111 |
|
|
-- A linked list of all indirectly access attributes, which includes all
|
112 |
|
|
-- those that require finalization.
|
113 |
|
|
|
114 |
|
|
procedure Initialize_Attributes (T : Task_Id);
|
115 |
|
|
-- Initialize all attributes created via Ada.Task_Attributes for T. This
|
116 |
|
|
-- must be called by the creator of the task, inside Create_Task, via
|
117 |
|
|
-- soft-link Initialize_Attributes_Link. On entry, abort must be deferred
|
118 |
|
|
-- and the caller must hold no locks
|
119 |
|
|
|
120 |
|
|
procedure Finalize_Attributes (T : Task_Id);
|
121 |
|
|
-- Finalize all attributes created via Ada.Task_Attributes for T.
|
122 |
|
|
-- This is to be called by the task after it is marked as terminated
|
123 |
|
|
-- (and before it actually dies), inside Vulnerable_Free_Task, via the
|
124 |
|
|
-- soft-link Finalize_Attributes_Link. On entry, abort must be deferred
|
125 |
|
|
-- and T.L must be write-locked.
|
126 |
|
|
|
127 |
|
|
end System.Tasking.Task_Attributes;
|