* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / ada / a-taside.adb
blob8599af7fbe39cd89de27c9375559d0ed6731a776
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . T A S K _ I D E N T I F I C A T I O N --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 with System.Address_Image;
35 with System.Parameters;
36 with System.Soft_Links;
37 with System.Task_Primitives.Operations;
38 with System.Tasking;
40 with Unchecked_Conversion;
42 pragma Warnings (Off);
43 -- Allow withing of non-Preelaborated units in Ada 2005 mode where this
44 -- package will be categorized as Preelaborate. See AI-362 for details.
45 -- It is safe in the context of the run-time to violate the rules!
47 with System.Tasking.Utilities;
48 -- Used for Abort_Tasks
50 pragma Warnings (On);
52 package body Ada.Task_Identification is
54 use System.Parameters;
56 package STPO renames System.Task_Primitives.Operations;
58 -----------------------
59 -- Local Subprograms --
60 -----------------------
62 function Convert_Ids (T : Task_Id) return System.Tasking.Task_Id;
63 function Convert_Ids (T : System.Tasking.Task_Id) return Task_Id;
64 pragma Inline (Convert_Ids);
65 -- Conversion functions between different forms of Task_Id
67 ---------
68 -- "=" --
69 ---------
71 function "=" (Left, Right : Task_Id) return Boolean is
72 begin
73 return System.Tasking."=" (Convert_Ids (Left), Convert_Ids (Right));
74 end "=";
76 -----------------
77 -- Abort_Task --
78 ----------------
80 procedure Abort_Task (T : Task_Id) is
81 begin
82 if T = Null_Task_Id then
83 raise Program_Error;
84 else
85 System.Tasking.Utilities.Abort_Tasks
86 (System.Tasking.Task_List'(1 => Convert_Ids (T)));
87 end if;
88 end Abort_Task;
90 -----------------
91 -- Convert_Ids --
92 -----------------
94 function Convert_Ids (T : Task_Id) return System.Tasking.Task_Id is
95 begin
96 return System.Tasking.Task_Id (T);
97 end Convert_Ids;
99 function Convert_Ids (T : System.Tasking.Task_Id) return Task_Id is
100 begin
101 return Task_Id (T);
102 end Convert_Ids;
104 ------------------
105 -- Current_Task --
106 ------------------
108 function Current_Task return Task_Id is
109 begin
110 return Convert_Ids (System.Task_Primitives.Operations.Self);
111 end Current_Task;
113 -----------
114 -- Image --
115 -----------
117 function Image (T : Task_Id) return String is
118 function To_Address is new
119 Unchecked_Conversion (Task_Id, System.Address);
121 begin
122 if T = Null_Task_Id then
123 return "";
125 elsif T.Common.Task_Image_Len = 0 then
126 return System.Address_Image (To_Address (T));
128 else
129 return T.Common.Task_Image (1 .. T.Common.Task_Image_Len)
130 & "_" & System.Address_Image (To_Address (T));
131 end if;
132 end Image;
134 -----------------
135 -- Is_Callable --
136 -----------------
138 function Is_Callable (T : Task_Id) return Boolean is
139 Result : Boolean;
140 Id : constant System.Tasking.Task_Id := Convert_Ids (T);
141 begin
142 if T = Null_Task_Id then
143 raise Program_Error;
144 else
145 System.Soft_Links.Abort_Defer.all;
147 if Single_Lock then
148 STPO.Lock_RTS;
149 end if;
151 STPO.Write_Lock (Id);
152 Result := Id.Callable;
153 STPO.Unlock (Id);
155 if Single_Lock then
156 STPO.Unlock_RTS;
157 end if;
159 System.Soft_Links.Abort_Undefer.all;
160 return Result;
161 end if;
162 end Is_Callable;
164 -------------------
165 -- Is_Terminated --
166 -------------------
168 function Is_Terminated (T : Task_Id) return Boolean is
169 Result : Boolean;
170 Id : constant System.Tasking.Task_Id := Convert_Ids (T);
172 use System.Tasking;
174 begin
175 if T = Null_Task_Id then
176 raise Program_Error;
177 else
178 System.Soft_Links.Abort_Defer.all;
180 if Single_Lock then
181 STPO.Lock_RTS;
182 end if;
184 STPO.Write_Lock (Id);
185 Result := Id.Common.State = Terminated;
186 STPO.Unlock (Id);
188 if Single_Lock then
189 STPO.Unlock_RTS;
190 end if;
192 System.Soft_Links.Abort_Undefer.all;
193 return Result;
194 end if;
195 end Is_Terminated;
197 end Ada.Task_Identification;