1------------------------------------------------------------------------------
2--                                                                          --
3--                GNU ADA 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-2003, Ada Core Technologies               --
11--                                                                          --
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,  59 Temple Place - Suite 330,  Boston, --
21-- MA 02111-1307, USA.                                                      --
22--                                                                          --
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.                                      --
29--                                                                          --
30-- GNARL was developed by the GNARL team at Florida State University.       --
31-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
32--                                                                          --
33------------------------------------------------------------------------------
34
35--  This package provides support for the body of Ada.Task_Attributes.
36
37with Ada.Finalization;
38--  used for Limited_Controlled
39
40with System.Storage_Elements;
41--  used for Integer_Address
42
43package System.Tasking.Task_Attributes is
44
45   type Attribute is new Integer;
46   --  A stand-in for the generic formal type of Ada.Task_Attributes
47   --  in the following declarations.
48
49   type Node;
50   type Access_Node is access all Node;
51   --  This needs comments ???
52
53   type Dummy_Wrapper;
54   type Access_Dummy_Wrapper is access all Dummy_Wrapper;
55   for Access_Dummy_Wrapper'Storage_Size use 0;
56   --  This is a stand-in for the generic type Wrapper defined in
57   --  Ada.Task_Attributes. The real objects allocated are always
58   --  of type Wrapper, no Dummy_Wrapper objects are ever created.
59
60   type Deallocator is access procedure (P : in out Access_Node);
61   --  Called to deallocate an Wrapper. P is a pointer to a Node within.
62
63   type Instance;
64
65   type Access_Instance is access all Instance;
66
67   type Instance is new Ada.Finalization.Limited_Controlled with record
68      Deallocate    : Deallocator;
69      Initial_Value : aliased System.Storage_Elements.Integer_Address;
70
71      Index : Direct_Index;
72      --  The index of the TCB location used by this instantiation,
73      --  if it is stored in the TCB, otherwise zero.
74
75      Next : Access_Instance;
76      --  Next instance in All_Attributes list.
77   end record;
78
79   procedure Finalize (X : in out Instance);
80
81   type Node is record
82      Wrapper  : Access_Dummy_Wrapper;
83      Instance : Access_Instance;
84      Next     : Access_Node;
85   end record;
86
87   --  The following type is a stand-in for the actual
88   --  wrapper type, which is different for each instantiation
89   --  of Ada.Task_Attributes.
90
91   type Dummy_Wrapper is record
92      Noed : aliased Node;
93
94      Value : aliased Attribute;
95      --  The generic formal type, may be controlled
96   end record;
97
98   for Dummy_Wrapper'Alignment use Standard'Maximum_Alignment;
99   --  A number of unchecked conversions involving Dummy_Wrapper_Access
100   --  sources are performed in other units (e.g. Ada.Task_Attributes).
101   --  Ensure that the designated object is always strictly enough aligned.
102
103   In_Use : Direct_Index_Vector := 0;
104   --  is True for direct indices that are already used.
105
106   All_Attributes : Access_Instance;
107   --  A linked list of all indirectly access attributes,
108   --  which includes all those that require finalization.
109
110   procedure Initialize_Attributes (T : Task_ID);
111   --  Initialize all attributes created via Ada.Task_Attributes for T.
112   --  This must be called by the creator of the task, inside Create_Task,
113   --  via soft-link Initialize_Attributes_Link. On entry, abortion must
114   --  be deferred and the caller must hold no locks
115
116   procedure Finalize_Attributes (T : Task_ID);
117   --  Finalize all attributes created via Ada.Task_Attributes for T.
118   --  This is to be called by the task after it is marked as terminated
119   --  (and before it actually dies), inside Vulnerable_Free_Task, via the
120   --  soft-link Finalize_Attributes_Link. On entry, abortion must be deferred
121   --  and T.L must be write-locked.
122
123end System.Tasking.Task_Attributes;
124