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-2007, AdaCore --
12 -- GNARL 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 2, or (at your option) any later ver- --
15 -- sion. GNARL 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. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
33 ------------------------------------------------------------------------------
35 -- This package provides support for the body of Ada.Task_Attributes
37 with Ada
.Finalization
;
38 -- Used for Limited_Controlled
40 with System
.Storage_Elements
;
41 -- Used for Integer_Address
43 package System
.Tasking
.Task_Attributes
is
45 type Attribute
is new Integer;
46 -- A stand-in for the generic formal type of Ada.Task_Attributes
47 -- in the following declarations.
50 type Access_Node
is access all Node
;
51 -- This needs comments ???
53 function To_Access_Node
is new Ada
.Unchecked_Conversion
54 (Access_Address
, Access_Node
);
55 -- Used to fetch pointer to indirect attribute list. Declaration is in
56 -- spec to avoid any problems with aliasing assumptions.
59 type Access_Dummy_Wrapper
is access all Dummy_Wrapper
;
60 pragma No_Strict_Aliasing
(Access_Dummy_Wrapper
);
61 -- Needed to avoid possible incorrect aliasing situations from
62 -- instantiation of Unchecked_Conversion in body of Ada.Task_Attributes.
64 for Access_Dummy_Wrapper
'Storage_Size use 0;
65 -- Access_Dummy_Wrapper is a stand-in for the generic type Wrapper defined
66 -- in Ada.Task_Attributes. The real objects allocated are always
67 -- of type Wrapper, no Dummy_Wrapper objects are ever created.
69 type Deallocator
is access procedure (P
: in out Access_Node
);
70 -- Called to deallocate an Wrapper. P is a pointer to a Node within
74 type Access_Instance
is access all Instance
;
76 type Instance
is new Ada
.Finalization
.Limited_Controlled
with record
77 Deallocate
: Deallocator
;
78 Initial_Value
: aliased System
.Storage_Elements
.Integer_Address
;
81 -- The index of the TCB location used by this instantiation, if it is
82 -- stored in the TCB, otherwise zero.
84 Next
: Access_Instance
;
85 -- Next instance in All_Attributes list
88 procedure Finalize
(X
: in out Instance
);
91 Wrapper
: Access_Dummy_Wrapper
;
92 Instance
: Access_Instance
;
96 -- The following type is a stand-in for the actual wrapper type, which is
97 -- different for each instantiation of Ada.Task_Attributes.
99 type Dummy_Wrapper
is record
100 Dummy_Node
: aliased Node
;
102 Value
: aliased Attribute
;
103 -- The generic formal type, may be controlled
106 for Dummy_Wrapper
'Alignment use Standard
'Maximum_Alignment;
107 -- A number of unchecked conversions involving Dummy_Wrapper_Access
108 -- sources are performed in other units (e.g. Ada.Task_Attributes).
109 -- Ensure that the designated object is always strictly enough aligned.
111 In_Use
: Direct_Index_Vector
:= 0;
112 -- Set True for direct indices that are already used (True??? type???)
114 All_Attributes
: Access_Instance
;
115 -- A linked list of all indirectly access attributes, which includes all
116 -- those that require finalization.
118 procedure Initialize_Attributes
(T
: Task_Id
);
119 -- Initialize all attributes created via Ada.Task_Attributes for T. This
120 -- must be called by the creator of the task, inside Create_Task, via
121 -- soft-link Initialize_Attributes_Link. On entry, abort must be deferred
122 -- and the caller must hold no locks
124 procedure Finalize_Attributes
(T
: Task_Id
);
125 -- Finalize all attributes created via Ada.Task_Attributes for T.
126 -- This is to be called by the task after it is marked as terminated
127 -- (and before it actually dies), inside Vulnerable_Free_Task, via the
128 -- soft-link Finalize_Attributes_Link. On entry, abort must be deferred
129 -- and T.L must be write-locked.
131 end System
.Tasking
.Task_Attributes
;