OSDN Git Service

2005-03-08 Javier Miranda <miranda@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-gloloc.adb
index 73d69df..92fd2ff 100644 (file)
@@ -6,9 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.6 $                               --
---                                                                          --
---           Copyright (C) 1999-2001 Ada Core Technologies, Inc.            --
+--          Copyright (C) 1999-2002 Free Software Foundation, Inc.          --
 --                                                                          --
 -- GNAT 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- --
 -- however invalidate  any other reasons why  the executable file  might be --
 -- covered by the  GNU Public License.                                      --
 --                                                                          --
--- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).   --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with GNAT.Task_Lock;
+with System.Soft_Links;
+--  used for Lock_Task, Unlock_Task
 
 package body System.Global_Locks is
 
    type String_Access is access String;
 
-   package TSL renames GNAT.Task_Lock;
-
    Dir_Separator : Character;
    pragma Import (C, Dir_Separator, "__gnat_dir_separator");
 
-   type Lock_File_Entry is
-      record
-         Dir  : String_Access;
-         File : String_Access;
-      end record;
+   type Lock_File_Entry is record
+      Dir  : String_Access;
+      File : String_Access;
+   end record;
 
    Last_Lock  : Lock_Type := Null_Lock;
    Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry;
@@ -67,9 +64,7 @@ package body System.Global_Locks is
    -- Acquire_Lock --
    ------------------
 
-   procedure Acquire_Lock
-     (Lock : in out Lock_Type)
-   is
+   procedure Acquire_Lock (Lock : in out Lock_Type) is
    begin
       Lock_File
         (Lock_Table (Lock).Dir.all,
@@ -80,17 +75,14 @@ package body System.Global_Locks is
    -- Create_Lock --
    -----------------
 
-   procedure Create_Lock
-     (Lock : out Lock_Type;
-      Name : in String)
-   is
+   procedure Create_Lock (Lock : out Lock_Type; Name : in String) is
       L : Lock_Type;
 
    begin
-      TSL.Lock;
+      System.Soft_Links.Lock_Task.all;
       Last_Lock := Last_Lock + 1;
       L := Last_Lock;
-      TSL.Unlock;
+      System.Soft_Links.Unlock_Task.all;
 
       if L > Lock_Table'Last then
          raise Lock_Error;
@@ -98,10 +90,8 @@ package body System.Global_Locks is
 
       for J in reverse Name'Range loop
          if Name (J) = Dir_Separator then
-            Lock_Table (L).Dir
-              := new String'(Name (Name'First .. J - 1));
-            Lock_Table (L).File
-              := new String'(Name (J + 1 .. Name'Last));
+            Lock_Table (L).Dir := new String'(Name (Name'First .. J - 1));
+            Lock_Table (L).File := new String'(Name (J + 1 .. Name'Last));
             exit;
          end if;
       end loop;
@@ -135,9 +125,11 @@ package body System.Global_Locks is
          if Try_Lock (C_Dir'Address, C_File'Address) = 1 then
             return;
          end if;
+
          exit when I = Retries;
          delay Wait;
       end loop;
+
       raise Lock_Error;
    end Lock_File;
 
@@ -145,12 +137,10 @@ package body System.Global_Locks is
    -- Release_Lock --
    ------------------
 
-   procedure Release_Lock
-     (Lock : in out Lock_Type)
-   is
+   procedure Release_Lock (Lock : in out Lock_Type) is
       S : aliased String :=
-        Lock_Table (Lock).Dir.all & Dir_Separator &
-        Lock_Table (Lock).File.all & ASCII.NUL;
+            Lock_Table (Lock).Dir.all & Dir_Separator &
+            Lock_Table (Lock).File.all & ASCII.NUL;
 
       procedure unlink (A : System.Address);
       pragma Import (C, unlink, "unlink");