OSDN Git Service

PR 33870
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-taskin.adb
index f38f952..214d7a4 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2006, 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- --
@@ -41,19 +41,42 @@ with System.Task_Primitives.Operations;
 with System.Storage_Elements;
 --  Needed for initializing Stack_Info.Size
 
-with System.Parameters;
---  Used for Adjust_Storage_Size
-
 package body System.Tasking is
 
    package STPO renames System.Task_Primitives.Operations;
 
+   ---------------------
+   -- Detect_Blocking --
+   ---------------------
+
+   function Detect_Blocking return Boolean is
+      GL_Detect_Blocking : Integer;
+      pragma Import (C, GL_Detect_Blocking, "__gl_detect_blocking");
+      --  Global variable exported by the binder generated file.
+      --  A value equal to 1 indicates that pragma Detect_Blocking is active,
+      --  while 0 is used for the pragma not being present.
+
+   begin
+      return GL_Detect_Blocking = 1;
+   end Detect_Blocking;
+
    ----------
    -- Self --
    ----------
 
    function Self return Task_Id renames STPO.Self;
 
+   ------------------
+   -- Storage_Size --
+   ------------------
+
+   function Storage_Size (T : Task_Id) return System.Parameters.Size_Type is
+   begin
+      return
+         System.Parameters.Size_Type
+           (T.Common.Compiler_Data.Pri_Stack_Info.Size);
+   end Storage_Size;
+
    ---------------------
    -- Initialize_ATCB --
    ---------------------
@@ -92,6 +115,9 @@ package body System.Tasking is
       T.Common.Elaborated := Elaborated;
       T.Common.Activation_Failed := False;
       T.Common.Task_Info := Task_Info;
+      T.Common.Global_Task_Lock_Nesting := 0;
+      T.Common.Fall_Back_Handler := null;
+      T.Common.Specific_Handler  := null;
 
       if T.Common.Parent = null then
          --  For the environment task, the adjusted stack size is
@@ -110,14 +136,18 @@ package body System.Tasking is
              (Parameters.Adjust_Storage_Size (Stack_Size));
       end if;
 
-      --  Link the task into the list of all tasks.
+      --  Link the task into the list of all tasks
 
       T.Common.All_Tasks_Link := All_Tasks_List;
       All_Tasks_List := T;
    end Initialize_ATCB;
 
+   ----------------
+   -- Initialize --
+   ----------------
+
    Main_Task_Image : constant String := "main_task";
-   --  Image of environment task.
+   --  Image of environment task
 
    Main_Priority : Integer;
    pragma Import (C, Main_Priority, "__gl_main_priority");
@@ -125,26 +155,21 @@ package body System.Tasking is
    --  Priority, because we use the value -1 to indicate the default
    --  main priority, and that is of course not in Priority'range.
 
-   ----------------------------
-   -- Tasking Initialization --
-   ----------------------------
-
-   --  This block constitutes the first part of the initialization of the
-   --  GNARL. This includes creating data structures to make the initial thread
-   --  into the environment task. The last part of the initialization is done
-   --  in System.Tasking.Initialization or System.Tasking.Restricted.Stages.
-   --  All the initializations used to be in Tasking.Initialization, but this
-   --  is no longer possible with the run time simplification (including
-   --  optimized PO and the restricted run time) since one cannot rely on
-   --  System.Tasking.Initialization being present, as was done before.
-
-begin
-   declare
+   Initialized : Boolean := False;
+   --  Used to prevent multiple calls to Initialize
+
+   procedure Initialize is
       T             : Task_Id;
       Success       : Boolean;
       Base_Priority : Any_Priority;
 
    begin
+      if Initialized then
+         return;
+      end if;
+
+      Initialized := True;
+
       --  Initialize Environment Task
 
       if Main_Priority = Unspecified_Priority then
@@ -170,5 +195,6 @@ begin
       --  in ravenscar mode. Rest of the initialization is done in Init_RTS.
 
       T.Entry_Calls (1).Self := T;
-   end;
+   end Initialize;
+
 end System.Tasking;