OSDN Git Service

* Makefile.in (reload1.o-warn): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-tasuti.adb
index 8877c78..6767f29 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---         Copyright (C) 1992-2005, Free Software Foundation, Inc.          --
+--         Copyright (C) 1992-2007, Free Software Foundation, Inc.          --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -43,7 +43,6 @@ with System.Tasking.Debug;
 
 with System.Task_Primitives.Operations;
 --  used for Write_Lock
---           Set_Priority
 --           Wakeup
 --           Unlock
 --           Sleep
@@ -59,9 +58,6 @@ with System.Tasking.Queuing;
 --  used for Dequeue_Call
 --           Dequeue_Head
 
-with System.Tasking.Debug;
---  used for Trace
-
 with System.Parameters;
 --  used for Single_Lock
 --           Runtime_Traces
@@ -69,8 +65,6 @@ with System.Parameters;
 with System.Traces.Tasking;
 --  used for Send_Trace_Info
 
-with Unchecked_Conversion;
-
 package body System.Tasking.Utilities is
 
    package STPO renames System.Task_Primitives.Operations;
@@ -117,9 +111,6 @@ package body System.Tasking.Utilities is
    -- Abort_Tasks --
    -----------------
 
-   --  Compiler interface only: Do not call from within the RTS,
-
-   --  except in the implementation of Ada.Task_Identification.
    --  This must be called to implement the abort statement.
    --  Much of the actual work of the abort is done by the abortee,
    --  via the Abort_Handler signal handler, and propagation of the
@@ -131,6 +122,17 @@ package body System.Tasking.Utilities is
       P       : Task_Id;
 
    begin
+      --  If pragma Detect_Blocking is active then Program_Error must be
+      --  raised if this potentially blocking operation is called from a
+      --  protected action.
+
+      if System.Tasking.Detect_Blocking
+        and then Self_Id.Common.Protected_Action_Nesting > 0
+      then
+         Ada.Exceptions.Raise_Exception
+           (Program_Error'Identity, "potentially blocking operation");
+      end if;
+
       Initialization.Defer_Abort_Nestable (Self_Id);
 
       --  ?????
@@ -294,7 +296,7 @@ package body System.Tasking.Utilities is
 
       if Parent /= Environment_Task then
 
-         --  We can not lock three tasks at the same time, so defer the
+         --  We cannot lock three tasks at the same time, so defer the
          --  operations on the parent.
 
          Parent_Needs_Updating := True;
@@ -379,10 +381,10 @@ package body System.Tasking.Utilities is
             --  Our parent should wait in Phase 1 of Complete_Master.
 
             Master_Completion_Phase := 1;
-            pragma Assert (Self_ID.Awake_Count = 1);
+            pragma Assert (Self_ID.Awake_Count >= 1);
          end if;
 
-      --  We are accepting with a terminate alternative.
+      --  We are accepting with a terminate alternative
 
       else
          if Self_ID.Open_Accepts = null then
@@ -451,8 +453,6 @@ package body System.Tasking.Utilities is
             Write_Lock (C);
          end loop;
 
-         pragma Assert (P.Awake_Count /= 0);
-
          if P.Common.State = Master_Phase_2_Sleep
            and then C.Master_of_Task = P.Master_Within
          then
@@ -475,7 +475,6 @@ package body System.Tasking.Utilities is
       C.Awake_Count := C.Awake_Count - 1;
 
       if Task_Completed then
-         pragma Assert (Self_ID.Awake_Count = 0);
          C.Alive_Count := C.Alive_Count - 1;
       end if;
 
@@ -494,9 +493,11 @@ package body System.Tasking.Utilities is
       --  C has a parent, P.
 
       loop
-         --  Notify P that C has gone passive.
+         --  Notify P that C has gone passive
 
-         P.Awake_Count := P.Awake_Count - 1;
+         if P.Awake_Count > 0 then
+            P.Awake_Count := P.Awake_Count - 1;
+         end if;
 
          if Task_Completed and then C.Alive_Count = 0 then
             P.Alive_Count := P.Alive_Count - 1;
@@ -516,7 +517,7 @@ package body System.Tasking.Utilities is
          Write_Lock (C);
       end loop;
 
-      --  P has non-passive dependents.
+      --  P has non-passive dependents
 
       if P.Common.State = Master_Completion_Sleep
         and then C.Master_of_Task = P.Master_Within