1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
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 --
9 -- Copyright (C) 1991-1994, Florida State University --
10 -- Copyright (C) 1995-2010, AdaCore --
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. --
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. --
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/>. --
28 -- GNARL was developed by the GNARL team at Florida State University. --
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 ------------------------------------------------------------------------------
33 -- This package provides support for the body of Ada.Task_Attributes
35 with Ada
.Finalization
;
37 with System
.Storage_Elements
;
39 package System
.Tasking
.Task_Attributes
is
41 type Attribute
is new Integer;
42 -- A stand-in for the generic formal type of Ada.Task_Attributes
43 -- in the following declarations.
46 type Access_Node
is access all Node
;
47 -- This needs comments ???
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.
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.
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.
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
70 type Access_Instance
is access all Instance
;
72 type Instance
is new Ada
.Finalization
.Limited_Controlled
with record
73 Deallocate
: Deallocator
;
74 Initial_Value
: aliased System
.Storage_Elements
.Integer_Address
;
77 -- The index of the TCB location used by this instantiation, if it is
78 -- stored in the TCB, otherwise zero.
80 Next
: Access_Instance
;
81 -- Next instance in All_Attributes list
84 procedure Finalize
(X
: in out Instance
);
87 Wrapper
: Access_Dummy_Wrapper
;
88 Instance
: Access_Instance
;
92 -- The following type is a stand-in for the actual wrapper type, which is
93 -- different for each instantiation of Ada.Task_Attributes.
95 type Dummy_Wrapper
is record
96 Dummy_Node
: aliased Node
;
98 Value
: aliased Attribute
;
99 -- The generic formal type, may be controlled
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.
107 In_Use
: Direct_Index_Vector
:= 0;
108 -- Set True for direct indexes that are already used (True??? type???)
110 All_Attributes
: Access_Instance
;
111 -- A linked list of all indirectly access attributes, which includes all
112 -- those that require finalization.
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
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.
127 end System
.Tasking
.Task_Attributes
;