* rtl.h (struct rtx_def): Update comments.
[official-gcc.git] / gcc / ada / 5vtpopde.adb
blob419f8063e19c10e233a524286c2607868f2dab0e
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.DEC --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 2000-2001 Free Software Foundation, Inc. --
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. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This package is for OpenVMS/Alpha
38 with System.OS_Interface;
39 with System.Tasking;
40 with Unchecked_Conversion;
42 package body System.Task_Primitives.Operations.DEC is
44 use System.OS_Interface;
45 use System.Tasking;
46 use System.Aux_DEC;
47 use type Interfaces.C.int;
49 -- The FAB_RAB_Type specifies where the context field (the calling
50 -- task) is stored. Other fields defined for FAB_RAB aren't need and
51 -- so are ignored.
53 type FAB_RAB_Type is record
54 CTX : Unsigned_Longword;
55 end record;
57 for FAB_RAB_Type use record
58 CTX at 24 range 0 .. 31;
59 end record;
61 for FAB_RAB_Type'Size use 224;
63 type FAB_RAB_Access_Type is access all FAB_RAB_Type;
65 -----------------------
66 -- Local Subprograms --
67 -----------------------
69 function To_Unsigned_Longword is new
70 Unchecked_Conversion (Task_ID, Unsigned_Longword);
72 function To_Task_Id is new
73 Unchecked_Conversion (Unsigned_Longword, Task_ID);
75 function To_FAB_RAB is new
76 Unchecked_Conversion (Address, FAB_RAB_Access_Type);
78 ---------------------------
79 -- Interrupt_AST_Handler --
80 ---------------------------
82 procedure Interrupt_AST_Handler (ID : Address) is
83 Result : Interfaces.C.int;
84 AST_Self_ID : Task_ID := To_Task_Id (ID);
86 begin
87 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
88 pragma Assert (Result = 0);
89 end Interrupt_AST_Handler;
91 ---------------------
92 -- RMS_AST_Handler --
93 ---------------------
95 procedure RMS_AST_Handler (ID : Address) is
96 AST_Self_ID : Task_ID := To_Task_Id (To_FAB_RAB (ID).CTX);
97 Result : Interfaces.C.int;
99 begin
100 AST_Self_ID.Common.LL.AST_Pending := False;
101 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
102 pragma Assert (Result = 0);
103 end RMS_AST_Handler;
105 ----------
106 -- Self --
107 ----------
109 function Self return Unsigned_Longword is
110 Self_ID : Task_ID := Self;
112 begin
113 Self_ID.Common.LL.AST_Pending := True;
114 return To_Unsigned_Longword (Self);
115 end Self;
117 -------------------------
118 -- Starlet_AST_Handler --
119 -------------------------
121 procedure Starlet_AST_Handler (ID : Address) is
122 Result : Interfaces.C.int;
123 AST_Self_ID : Task_ID := To_Task_Id (ID);
125 begin
126 AST_Self_ID.Common.LL.AST_Pending := False;
127 Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access);
128 pragma Assert (Result = 0);
129 end Starlet_AST_Handler;
131 ----------------
132 -- Task_Synch --
133 ----------------
135 procedure Task_Synch is
136 Synch_Self_ID : Task_ID := Self;
138 begin
139 Write_Lock (Synch_Self_ID);
140 Synch_Self_ID.Common.State := AST_Server_Sleep;
142 while Synch_Self_ID.Common.LL.AST_Pending loop
143 Sleep (Synch_Self_ID, AST_Server_Sleep);
144 end loop;
146 Synch_Self_ID.Common.State := Runnable;
147 Unlock (Synch_Self_ID);
148 end Task_Synch;
150 end System.Task_Primitives.Operations.DEC;