The system unit System.Atomic_Counters which provides an atomic counter type, along with increment, decrement and test operations, available to user programs.
Tested on x86_64-pc-linux-gnu, committed on trunk 2014-10-17 Robert Dewar <de...@adacore.com> * gnat_rm.texi: Document System.Atomic_Counters. * impunit.adb: Add System.Atomic_Counters (s-atocou.ads) to the list of user- accessible units added as children of System. * s-atocou.ads: Update comment.
Index: gnat_rm.texi =================================================================== --- gnat_rm.texi (revision 216367) +++ gnat_rm.texi (working copy) @@ -661,6 +661,7 @@ * Interfaces.VxWorks.IO (i-vxwoio.ads):: * System.Address_Image (s-addima.ads):: * System.Assertions (s-assert.ads):: +* System.Atomic_Counters (s-atocou.ads):: * System.Memory (s-memory.ads):: * System.Multiprocessors (s-multip.ads):: * System.Multiprocessors.Dispatching_Domains (s-mudido.ads):: @@ -19074,6 +19075,7 @@ * Interfaces.VxWorks.IO (i-vxwoio.ads):: * System.Address_Image (s-addima.ads):: * System.Assertions (s-assert.ads):: +* System.Atomic_Counters (s-atocou.ads):: * System.Memory (s-memory.ads):: * System.Multiprocessors (s-multip.ads):: * System.Multiprocessors.Dispatching_Domains (s-mudido.ads):: @@ -20585,6 +20587,18 @@ by an run-time assertion failure, as well as the routine that is used internally to raise this assertion. +@node System.Atomic_Counters (s-atocou.ads) +@section @code{System.Atomic_Counters} (@file{s-atocou.ads}) +@cindex @code{System.Atomic_Counters} (@file{s-atocou.ads}) + +@noindent +This package provides the declaration of an atomic counter type, +together with efficient routines (using hardware +synchronization primitives) for incrementing, decrementing, +and testing of these counters. This package is implemented +on most targets, including all Alpha, ia64, PowerPC, SPARC V9, +x86, and x86_64 platforms. + @node System.Memory (s-memory.ads) @section @code{System.Memory} (@file{s-memory.ads}) @cindex @code{System.Memory} (@file{s-memory.ads}) Index: impunit.adb =================================================================== --- impunit.adb (revision 216367) +++ impunit.adb (working copy) @@ -367,6 +367,7 @@ -------------------------------------- ("s-addima", F), -- System.Address_Image + ("s-atocou", F), -- System.Atomic_Counters ("s-assert", F), -- System.Assertions ("s-diflio", F), -- System.Dim.Float_IO ("s-diinio", F), -- System.Dim.Integer_IO Index: s-atocou.ads =================================================================== --- s-atocou.ads (revision 216367) +++ s-atocou.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2011-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 2011-2014, 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- -- @@ -37,8 +37,6 @@ -- - all x86 platforms -- - all x86_64 platforms --- Why isn't this package available to application programs??? - package System.Atomic_Counters is pragma Preelaborate; @@ -59,20 +57,19 @@ function Decrement (Item : in out Atomic_Counter) return Boolean; pragma Inline_Always (Decrement); - -- Decrements value of atomic counter, returns True when value reach zero. + -- Decrements value of atomic counter, returns True when value reach zero function Is_One (Item : Atomic_Counter) return Boolean; pragma Inline_Always (Is_One); - -- Returns True when value of the atomic counter is one. + -- Returns True when value of the atomic counter is one procedure Initialize (Item : out Atomic_Counter); pragma Inline_Always (Initialize); -- Initialize counter by setting its value to one. This subprogram is - -- intended to be used in special cases when counter object can't be + -- intended to be used in special cases when the counter object cannot be -- initialized in standard way. private - type Unsigned_32 is mod 2 ** 32; type Atomic_Counter is limited record