diff options
Diffstat (limited to 'gcc/ada/a-stzunb-shared.adb')
-rw-r--r-- | gcc/ada/a-stzunb-shared.adb | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/gcc/ada/a-stzunb-shared.adb b/gcc/ada/a-stzunb-shared.adb index 965d856e182..18fe75b8c54 100644 --- a/gcc/ada/a-stzunb-shared.adb +++ b/gcc/ada/a-stzunb-shared.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, 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- -- @@ -50,16 +50,6 @@ package body Ada.Strings.Wide_Wide_Unbounded is -- align the returned memory on the maximum alignment as malloc does not -- know the target alignment. - procedure Sync_Add_And_Fetch - (Ptr : access Interfaces.Unsigned_32; - Value : Interfaces.Unsigned_32); - pragma Import (Intrinsic, Sync_Add_And_Fetch, "__sync_add_and_fetch_4"); - - function Sync_Sub_And_Fetch - (Ptr : access Interfaces.Unsigned_32; - Value : Interfaces.Unsigned_32) return Interfaces.Unsigned_32; - pragma Import (Intrinsic, Sync_Sub_And_Fetch, "__sync_sub_and_fetch_4"); - function Aligned_Max_Length (Max_Length : Natural) return Natural; -- Returns recommended length of the shared string which is greater or -- equal to specified length. Calculation take in sense alignment of @@ -638,12 +628,10 @@ package body Ada.Strings.Wide_Wide_Unbounded is function Can_Be_Reused (Item : Shared_Wide_Wide_String_Access; - Length : Natural) return Boolean - is - use Interfaces; + Length : Natural) return Boolean is begin return - Item.Counter = 1 + System.Atomic_Counters.Is_One (Item.Counter) and then Item.Max_Length >= Length and then Item.Max_Length <= Aligned_Max_Length (Length + Length / Growth_Factor); @@ -1304,7 +1292,7 @@ package body Ada.Strings.Wide_Wide_Unbounded is procedure Reference (Item : not null Shared_Wide_Wide_String_Access) is begin - Sync_Add_And_Fetch (Item.Counter'Access, 1); + System.Atomic_Counters.Increment (Item.Counter); end Reference; --------------------- @@ -2113,7 +2101,6 @@ package body Ada.Strings.Wide_Wide_Unbounded is ----------------- procedure Unreference (Item : not null Shared_Wide_Wide_String_Access) is - use Interfaces; procedure Free is new Ada.Unchecked_Deallocation @@ -2122,7 +2109,7 @@ package body Ada.Strings.Wide_Wide_Unbounded is Aux : Shared_Wide_Wide_String_Access := Item; begin - if Sync_Sub_And_Fetch (Aux.Counter'Access, 1) = 0 then + if System.Atomic_Counters.Decrement (Aux.Counter) then -- Reference counter of Empty_Shared_Wide_Wide_String must never -- reach zero. |