From patchwork Fri Oct 17 08:42:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 400450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 28FD71400BB for ; Fri, 17 Oct 2014 19:43:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=hzrbfPyp41ZjM3nMRGyZzX6ucMpNlpJEz601f3edZJToQ0ledu gEX83qIkjZCPklf2xSkJ9LnsvcjmfobCiqYwLWKwD03UDOJFBE/fx9qzvvkDJCLk oqHUhC9xXD0BkN3CN7wyuQT+Wk5L+Dvt/pgUPOryZR6uD+uzJ24yriU5w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=+q0pXTu+VIU3DBzftGOLydcMtLA=; b=NiKMfiCrWdO1bwlY7oKf 2h7gP89FDUnvp6DpPlpVBG0rK9RsHnUjg51whMlXZQbynL+PZcVBsntb42sKB42n ncfh5j0LkMn6lqAQ21/brTKVn0FUc29m5BhWDQ0I9hFhl4s4R76Z2rwyw5hmskzB z7nsicELpjPHc80J1LLSqtE= Received: (qmail 5818 invoked by alias); 17 Oct 2014 08:42:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5733 invoked by uid 89); 17 Oct 2014 08:42:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 17 Oct 2014 08:42:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9167111631F; Fri, 17 Oct 2014 04:42:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RV2eMMDqlajt; Fri, 17 Oct 2014 04:42:52 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 8170D11631B; Fri, 17 Oct 2014 04:42:52 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 7FE7A91A7D; Fri, 17 Oct 2014 04:42:52 -0400 (EDT) Date: Fri, 17 Oct 2014 04:42:52 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Make System.Atomic_Counters available to user applications Message-ID: <20141017084252.GA4709@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 * 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