Patchwork [Ada] Lock-free implementation of protected objects

login
register
mail settings
Submitter Arnaud Charlet
Date July 23, 2012, 8:02 a.m.
Message ID <20120723080250.GA28974@adacore.com>
Download mbox | patch
Permalink /patch/172567/
State New
Headers show

Comments

Arnaud Charlet - July 23, 2012, 8:02 a.m.
This patch implements a check in the runtime library that determines whether
the current target supports the atomic primitives up to 64 bits.

This should fix build failures on e.g. powerpc-darwin.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-07-23  Vincent Pucci  <pucci@adacore.com>

	* system-aix64.ads, system-aix.ads, system-darwin-ppc.ads,
	system-hpux.ads, system-linux-alpha.ads,
	system-linux-hppa.ads, system-linux-ppc.ads,
	system-linux-s390.ads, system-linux-s390x.ads,
	system-linux-sh4.ads, system-linux-sparc.ads,
	system-lynxos-ppc.ads, system-mingw.ads,
	system-solaris-sparc.ads, system-solaris-sparcv9.ads,
	system-vms_64.ads, * system-vxworks-arm.ads, system-vxworks-m68k.ads,
	system-vxworks-mips.ads, system-vxworks-ppc.ads,
	system-vxworks-sparcv9.ads: Support_Atomic_Primitives set to False.
	* system-darwin-x86.ads, system-darwin-x86_64.ads,
	system-freebsd-x86.ads, system-freebsd-x86_64.ads,
	system-hpux-ia64.ads, system-linux-ia64.ads, system-linux-x86.ads,
	system-linux-x86_64.ads, system-lynxos-x86.ads,
	system-mingw-x86_64.ads, system-solaris-x86.ads,
	system-solaris-x86_64.ads, system-vms-ia64.ads,
	system-vxworks-x86.ads: Support_Atomic_Primitives set to True.
	* s-atopri.adb (Lock_Free_Read_X): New body.
	(Lock_Free_Try_Write_X): Support_Atomic_Primitives check added.
	(Lock_Free_Try_Write_64): New body.
	* s-atopri.ads: New type uint.
	(Sync_Compare_And_Swap_64): __sync_val_compare_and_swap_8 intrinsic
	import.
	(Lock_Free_Read_X): Body moved to s-atopri.adb.
	(Lock_Free_Try_Write_64): Similar to other Lock_Free_Try_Write_X
	routines.
	* targparm.adb: New enumeration literal SAP
	(Support_Atomic_Primitives) for type Targparm_Tags. New constant
	SAP_Str. New component SAP_Str'Access for array Targparm_Str.
	(Get_Target_Parameters): Parse Support_Atomic_Primitives_On_Target
	flag.
	* targparm.ads: New back-end code generation flag
	Support_Atomic_Primitives_On_Target
Duncan Sands - July 23, 2012, 8:08 a.m.
Hi Arnaud,

> --- s-atopri.adb	(revision 189768)
> +++ s-atopri.adb	(working copy)
> @@ -31,6 +31,58 @@
>
>  package body System.Atomic_Primitives is
>
> +   ----------------------
> +   -- Lock_Free_Read_8 --
> +   ----------------------

...

> +   ----------------------
> +   -- Lock_Free_Read_16 --
> +   ----------------------

...

> +   ----------------------
> +   -- Lock_Free_Read_32 --
> +   ----------------------

There's a bunch or wrong comment formatting (notice how "----" lines aren't
always long enough except for the _8 case).

Ciao, Duncan.
Arnaud Charlet - July 23, 2012, 8:12 a.m.
> Hi Arnaud,

You removed Vincent who is the author of this patch, included here.

>> --- s-atopri.adb	(revision 189768)
>> +++ s-atopri.adb	(working copy)
>> @@ -31,6 +31,58 @@
>> 
>>  package body System.Atomic_Primitives is
>> 
>> +   ----------------------
>> +   -- Lock_Free_Read_8 --
>> +   ----------------------
> 
> ...
> 
>> +   ----------------------
>> +   -- Lock_Free_Read_16 --
>> +   ----------------------
> 
> ...
> 
>> +   ----------------------
>> +   -- Lock_Free_Read_32 --
>> +   ----------------------
> 
> There's a bunch or wrong comment formatting (notice how "----" lines aren't
> always long enough except for the _8 case).

Patch

Index: system-darwin-x86.ads
===================================================================
--- system-darwin-x86.ads	(revision 189768)
+++ system-darwin-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (Darwin/x86 Version)                            --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -158,6 +158,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-s390x.ads
===================================================================
--- system-linux-s390x.ads	(revision 189768)
+++ system-linux-s390x.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (GNU-Linux/s390x Version)                       --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -130,6 +130,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-alpha.ads
===================================================================
--- system-linux-alpha.ads	(revision 189768)
+++ system-linux-alpha.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                        (GNU-Linux/alpha Version)                         --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -130,6 +130,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-arm.ads
===================================================================
--- system-vxworks-arm.ads	(revision 189768)
+++ system-vxworks-arm.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (VxWorks Version ARM)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -145,6 +145,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-freebsd-x86_64.ads
===================================================================
--- system-freebsd-x86_64.ads	(revision 189768)
+++ system-freebsd-x86_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (FreeBSD/x86_64 Version)                         --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-hppa.ads
===================================================================
--- system-linux-hppa.ads	(revision 189768)
+++ system-linux-hppa.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                        (GNU/Linux-HPPA Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-s390.ads
===================================================================
--- system-linux-s390.ads	(revision 189768)
+++ system-linux-s390.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (GNU-Linux/s390 Version)                        --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -130,6 +130,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-solaris-sparcv9.ads
===================================================================
--- system-solaris-sparcv9.ads	(revision 189768)
+++ system-solaris-sparcv9.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                        (Solaris Sparcv9 Version)                         --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-mingw.ads
===================================================================
--- system-mingw.ads	(revision 189768)
+++ system-mingw.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                            (Windows Version)                             --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-ia64.ads
===================================================================
--- system-linux-ia64.ads	(revision 189768)
+++ system-linux-ia64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                        (GNU-Linux/ia64 Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -140,6 +140,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vms_64.ads
===================================================================
--- system-vms_64.ads	(revision 189768)
+++ system-vms_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                (OpenVMS 64bit GCC_ZCX DEC Threads Version)               --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -150,6 +150,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-sparcv9.ads
===================================================================
--- system-vxworks-sparcv9.ads	(revision 189768)
+++ system-vxworks-sparcv9.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                       (VxWorks Version Sparc/64)                         --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -147,6 +147,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: targparm.adb
===================================================================
--- targparm.adb	(revision 189768)
+++ targparm.adb	(working copy)
@@ -57,6 +57,7 @@ 
       PAS,  --   Preallocated_Stacks
       RTX,  --   RTX_RTSS_Kernel_Module
       SAG,  --   Support_Aggregates
+      SAP,  --   Support_Atomic_Primitives
       SCA,  --   Support_Composite_Assign
       SCC,  --   Support_Composite_Compare
       SCD,  --   Stack_Check_Default
@@ -93,6 +94,7 @@ 
    PAS_Str : aliased constant Source_Buffer := "Preallocated_Stacks";
    RTX_Str : aliased constant Source_Buffer := "RTX_RTSS_Kernel_Module";
    SAG_Str : aliased constant Source_Buffer := "Support_Aggregates";
+   SAP_Str : aliased constant Source_Buffer := "Support_Atomic_Primitives";
    SCA_Str : aliased constant Source_Buffer := "Support_Composite_Assign";
    SCC_Str : aliased constant Source_Buffer := "Support_Composite_Compare";
    SCD_Str : aliased constant Source_Buffer := "Stack_Check_Default";
@@ -129,6 +131,7 @@ 
       PAS_Str'Access,
       RTX_Str'Access,
       SAG_Str'Access,
+      SAP_Str'Access,
       SCA_Str'Access,
       SCC_Str'Access,
       SCD_Str'Access,
@@ -586,6 +589,7 @@ 
                      when PAS => Preallocated_Stacks_On_Target       := Result;
                      when RTX => RTX_RTSS_Kernel_Module_On_Target    := Result;
                      when SAG => Support_Aggregates_On_Target        := Result;
+                     when SAP => Support_Atomic_Primitives_On_Target := Result;
                      when SCA => Support_Composite_Assign_On_Target  := Result;
                      when SCC => Support_Composite_Compare_On_Target := Result;
                      when SCD => Stack_Check_Default_On_Target       := Result;
Index: system-linux-ppc.ads
===================================================================
--- system-linux-ppc.ads	(revision 189768)
+++ system-linux-ppc.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (GNU-Linux/PPC Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -140,6 +140,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: targparm.ads
===================================================================
--- targparm.ads	(revision 189768)
+++ targparm.ads	(working copy)
@@ -408,6 +408,14 @@ 
    --  are available. If any of these routines is not available, then
    --  this flag is False, and the use of aggregates is not permitted.
 
+   Support_Atomic_Primitives_On_Target : Boolean := False;
+   --  If this flag is True, then the back-end support GCC built-in atomic
+   --  operations for memory model such as atomic load or atomic compare
+   --  exchange (see the GCC manual for more information). If the flag is
+   --  False, then the back-end doesn't provide this support. Note this flag is
+   --  set to True only if the target supports all atomic primitives up to 64
+   --  bits. ??? To be modified.
+
    Support_Composite_Assign_On_Target : Boolean := True;
    --  The assignment of composite objects other than small records and
    --  arrays whose size is 64-bits or less and is set by an explicit
Index: system-aix64.ads
===================================================================
--- system-aix64.ads	(revision 189768)
+++ system-aix64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                           (PPC/AIX64 Version)                            --
 --                                                                          --
---          Copyright (C) 2009-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2009-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -142,6 +142,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-lynxos-ppc.ads
===================================================================
--- system-lynxos-ppc.ads	(revision 189768)
+++ system-lynxos-ppc.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                           (LynxOS PPC Version)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -146,6 +146,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-sh4.ads
===================================================================
--- system-linux-sh4.ads	(revision 189768)
+++ system-linux-sh4.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (GNU-Linux/sh4 Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -140,6 +140,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-solaris-x86.ads
===================================================================
--- system-solaris-x86.ads	(revision 189768)
+++ system-solaris-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (x86 Solaris Version)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: s-atopri.adb
===================================================================
--- s-atopri.adb	(revision 189768)
+++ s-atopri.adb	(working copy)
@@ -31,6 +31,58 @@ 
 
 package body System.Atomic_Primitives is
 
+   ----------------------
+   -- Lock_Free_Read_8 --
+   ----------------------
+
+   function Lock_Free_Read_8 (Ptr : Address) return uint8 is
+   begin
+      if Support_Atomic_Primitives then
+         return Atomic_Load_8 (Ptr, Acquire);
+      else
+         raise Program_Error;
+      end if;
+   end Lock_Free_Read_8;
+
+   ----------------------
+   -- Lock_Free_Read_16 --
+   ----------------------
+
+   function Lock_Free_Read_16 (Ptr : Address) return uint16 is
+   begin
+      if Support_Atomic_Primitives then
+         return Atomic_Load_16 (Ptr, Acquire);
+      else
+         raise Program_Error;
+      end if;
+   end Lock_Free_Read_16;
+
+   ----------------------
+   -- Lock_Free_Read_32 --
+   ----------------------
+
+   function Lock_Free_Read_32 (Ptr : Address) return uint32 is
+   begin
+      if Support_Atomic_Primitives then
+         return Atomic_Load_32 (Ptr, Acquire);
+      else
+         raise Program_Error;
+      end if;
+   end Lock_Free_Read_32;
+
+   ----------------------
+   -- Lock_Free_Read_64 --
+   ----------------------
+
+   function Lock_Free_Read_64 (Ptr : Address) return uint64 is
+   begin
+      if Support_Atomic_Primitives then
+         return Atomic_Load_64 (Ptr, Acquire);
+      else
+         raise Program_Error;
+      end if;
+   end Lock_Free_Read_64;
+
    ---------------------------
    -- Lock_Free_Try_Write_8 --
    ---------------------------
@@ -44,8 +96,13 @@ 
 
    begin
       if Expected /= Desired then
-         Actual := Sync_Compare_And_Swap_8 (Ptr, Expected, Desired);
 
+         if Support_Atomic_Primitives then
+            Actual := Sync_Compare_And_Swap_8 (Ptr, Expected, Desired);
+         else
+            raise Program_Error;
+         end if;
+
          if Actual /= Expected then
             Expected := Actual;
             return False;
@@ -68,8 +125,13 @@ 
 
    begin
       if Expected /= Desired then
-         Actual := Sync_Compare_And_Swap_16 (Ptr, Expected, Desired);
 
+         if Support_Atomic_Primitives then
+            Actual := Sync_Compare_And_Swap_16 (Ptr, Expected, Desired);
+         else
+            raise Program_Error;
+         end if;
+
          if Actual /= Expected then
             Expected := Actual;
             return False;
@@ -92,8 +154,13 @@ 
 
    begin
       if Expected /= Desired then
-         Actual := Sync_Compare_And_Swap_32 (Ptr, Expected, Desired);
 
+         if Support_Atomic_Primitives then
+            Actual := Sync_Compare_And_Swap_32 (Ptr, Expected, Desired);
+         else
+            raise Program_Error;
+         end if;
+
          if Actual /= Expected then
             Expected := Actual;
             return False;
@@ -102,4 +169,33 @@ 
 
       return True;
    end Lock_Free_Try_Write_32;
+
+   ----------------------------
+   -- Lock_Free_Try_Write_64 --
+   ----------------------------
+
+   function Lock_Free_Try_Write_64
+      (Ptr      : Address;
+       Expected : in out uint64;
+       Desired  : uint64) return Boolean
+   is
+      Actual : uint64;
+
+   begin
+      if Expected /= Desired then
+
+         if Support_Atomic_Primitives then
+            Actual := Sync_Compare_And_Swap_64 (Ptr, Expected, Desired);
+         else
+            raise Program_Error;
+         end if;
+
+         if Actual /= Expected then
+            Expected := Actual;
+            return False;
+         end if;
+      end if;
+
+      return True;
+   end Lock_Free_Try_Write_64;
 end System.Atomic_Primitives;
Index: s-atopri.ads
===================================================================
--- s-atopri.ads	(revision 189768)
+++ s-atopri.ads	(working copy)
@@ -36,6 +36,8 @@ 
 package System.Atomic_Primitives is
    pragma Preelaborate;
 
+   type uint is mod 2 ** Long_Integer'Size;
+
    type uint8  is mod 2**8
      with Size => 8;
 
@@ -121,10 +123,10 @@ 
    function Sync_Compare_And_Swap_64
      (Ptr      : Address;
       Expected : uint64;
-      Desired  : uint64) return Boolean;
+      Desired  : uint64) return uint64;
    pragma Import (Intrinsic,
                   Sync_Compare_And_Swap_64,
-                  "__sync_bool_compare_and_swap_8");
+                  "__sync_val_compare_and_swap_8");
 
    --------------------------
    -- Lock-free operations --
@@ -139,18 +141,13 @@ 
    --  * Lock_Free_Try_Write_N tries to write the Desired value into Ptr only
    --    if Expected and Desired mismatch.
 
-   function Lock_Free_Read_8 (Ptr : Address) return uint8 is
-     (Atomic_Load_8 (Ptr, Acquire));
+   function Lock_Free_Read_8 (Ptr : Address) return uint8;
 
-   function Lock_Free_Read_16 (Ptr : Address) return uint16 is
-      (Atomic_Load_16 (Ptr, Acquire));
+   function Lock_Free_Read_16 (Ptr : Address) return uint16;
 
-   function Lock_Free_Read_32 (Ptr : Address) return uint32 is
-      (Atomic_Load_32 (Ptr, Acquire));
+   function Lock_Free_Read_32 (Ptr : Address) return uint32;
 
-   function Lock_Free_Read_64
-     (Ptr : Address;
-      Model : Mem_Model := Seq_Cst) return uint64 renames Atomic_Load_64;
+   function Lock_Free_Read_64 (Ptr : Address) return uint64;
 
    function Lock_Free_Try_Write_8
       (Ptr      : Address;
@@ -169,8 +166,8 @@ 
 
    function Lock_Free_Try_Write_64
       (Ptr      : Address;
-       Expected : uint64;
-       Desired  : uint64) return Boolean renames Sync_Compare_And_Swap_64;
+       Expected : in out uint64;
+       Desired  : uint64) return Boolean;
 
    pragma Inline (Lock_Free_Read_8);
    pragma Inline (Lock_Free_Read_16);
Index: system-linux-x86_64.ads
===================================================================
--- system-linux-x86_64.ads	(revision 189768)
+++ system-linux-x86_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                       (GNU-Linux/x86-64 Version)                         --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -140,6 +140,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-x86.ads
===================================================================
--- system-linux-x86.ads	(revision 189768)
+++ system-linux-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (GNU-Linux/x86 Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -140,6 +140,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-ppc.ads
===================================================================
--- system-vxworks-ppc.ads	(revision 189771)
+++ system-vxworks-ppc.ads	(working copy)
@@ -154,6 +154,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-hpux.ads
===================================================================
--- system-hpux.ads	(revision 189768)
+++ system-hpux.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                             (HP-UX Version)                              --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-darwin-ppc.ads
===================================================================
--- system-darwin-ppc.ads	(revision 189768)
+++ system-darwin-ppc.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (Darwin/PPC Version)                            --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -158,6 +158,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-solaris-sparc.ads
===================================================================
--- system-solaris-sparc.ads	(revision 189768)
+++ system-solaris-sparc.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (SUN Solaris Version)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-lynxos-x86.ads
===================================================================
--- system-lynxos-x86.ads	(revision 189768)
+++ system-lynxos-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                           (LynxOS x86 Version)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -146,6 +146,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-m68k.ads
===================================================================
--- system-vxworks-m68k.ads	(revision 189768)
+++ system-vxworks-m68k.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (VxWorks version M68K)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -145,6 +145,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-hpux-ia64.ads
===================================================================
--- system-hpux-ia64.ads	(revision 189768)
+++ system-hpux-ia64.ads	(working copy)
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-solaris-x86_64.ads
===================================================================
--- system-solaris-x86_64.ads	(revision 189768)
+++ system-solaris-x86_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                        (x86-64 Solaris Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-mingw-x86_64.ads
===================================================================
--- system-mingw-x86_64.ads	(revision 189768)
+++ system-mingw-x86_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                            (Windows Version)                             --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-mips.ads
===================================================================
--- system-vxworks-mips.ads	(revision 189768)
+++ system-vxworks-mips.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (VxWorks Version Mips)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -145,6 +145,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-linux-sparc.ads
===================================================================
--- system-linux-sparc.ads	(revision 189768)
+++ system-linux-sparc.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (GNU/Linux-SPARC Version)                       --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -130,6 +130,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vms-ia64.ads
===================================================================
--- system-vms-ia64.ads	(revision 189768)
+++ system-vms-ia64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --            (OpenVMS 64bit Itanium GCC_ZCX DEC Threads Version)           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -150,6 +150,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-freebsd-x86.ads
===================================================================
--- system-freebsd-x86.ads	(revision 189768)
+++ system-freebsd-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                          (FreeBSD/x86 Version)                           --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -132,6 +132,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-aix.ads
===================================================================
--- system-aix.ads	(revision 189768)
+++ system-aix.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                            (AIX/PPC Version)                             --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -142,6 +142,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := False;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-darwin-x86_64.ads
===================================================================
--- system-darwin-x86_64.ads	(revision 189768)
+++ system-darwin-x86_64.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (Darwin/x86_64 Version)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -158,6 +158,7 @@ 
    Stack_Check_Probes        : constant Boolean := True;
    Stack_Check_Limits        : constant Boolean := False;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;
Index: system-vxworks-x86.ads
===================================================================
--- system-vxworks-x86.ads	(revision 189768)
+++ system-vxworks-x86.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                 S p e c                                  --
 --                         (VxWorks 5 Version x86)                          --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -145,6 +145,7 @@ 
    Stack_Check_Probes        : constant Boolean := False;
    Stack_Check_Limits        : constant Boolean := True;
    Support_Aggregates        : constant Boolean := True;
+   Support_Atomic_Primitives : constant Boolean := True;
    Support_Composite_Assign  : constant Boolean := True;
    Support_Composite_Compare : constant Boolean := True;
    Support_Long_Shifts       : constant Boolean := True;