annotate gcc/ada/libgnat/s-atocou.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . A T O M I C _ C O U N T E R S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2011-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides atomic counter on platforms where it is supported:
kono
parents:
diff changeset
33 -- - all Alpha platforms
kono
parents:
diff changeset
34 -- - all ia64 platforms
kono
parents:
diff changeset
35 -- - all PowerPC platforms
kono
parents:
diff changeset
36 -- - all SPARC V9 platforms
kono
parents:
diff changeset
37 -- - all x86 platforms
kono
parents:
diff changeset
38 -- - all x86_64 platforms
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package System.Atomic_Counters is
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 pragma Pure;
kono
parents:
diff changeset
43 pragma Preelaborate;
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 type Atomic_Counter is limited private;
kono
parents:
diff changeset
46 -- Type for atomic counter objects. Note, initial value of the counter is
kono
parents:
diff changeset
47 -- one. This allows using an atomic counter as member of record types when
kono
parents:
diff changeset
48 -- object of these types are created at library level in preelaborable
kono
parents:
diff changeset
49 -- compilation units.
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 -- Atomic_Counter is declared as private limited type to provide highest
kono
parents:
diff changeset
52 -- level of protection from unexpected use. All available operations are
kono
parents:
diff changeset
53 -- declared below, and this set should be as small as possible.
kono
parents:
diff changeset
54 -- Increment/Decrement operations for this type raise Program_Error on
kono
parents:
diff changeset
55 -- platforms not supporting the atomic primitives.
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 procedure Increment (Item : in out Atomic_Counter);
kono
parents:
diff changeset
58 pragma Inline_Always (Increment);
kono
parents:
diff changeset
59 -- Increments value of atomic counter.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 function Decrement (Item : in out Atomic_Counter) return Boolean;
kono
parents:
diff changeset
62 pragma Inline_Always (Decrement);
kono
parents:
diff changeset
63 -- Decrements value of atomic counter, returns True when value reach zero
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 function Is_One (Item : Atomic_Counter) return Boolean;
kono
parents:
diff changeset
66 pragma Inline_Always (Is_One);
kono
parents:
diff changeset
67 -- Returns True when value of the atomic counter is one
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 procedure Initialize (Item : out Atomic_Counter);
kono
parents:
diff changeset
70 pragma Inline_Always (Initialize);
kono
parents:
diff changeset
71 -- Initialize counter by setting its value to one. This subprogram is
kono
parents:
diff changeset
72 -- intended to be used in special cases when the counter object cannot be
kono
parents:
diff changeset
73 -- initialized in standard way.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 type Atomic_Unsigned is mod 2 ** 32 with Default_Value => 0, Atomic;
kono
parents:
diff changeset
76 -- Modular compatible atomic unsigned type.
kono
parents:
diff changeset
77 -- Increment/Decrement operations for this type are atomic only on
kono
parents:
diff changeset
78 -- supported platforms. See top of the file.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Increment
kono
parents:
diff changeset
81 (Item : aliased in out Atomic_Unsigned) with Inline_Always;
kono
parents:
diff changeset
82 -- Increments value of atomic counter
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Decrement
kono
parents:
diff changeset
85 (Item : aliased in out Atomic_Unsigned) return Boolean with Inline_Always;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Decrement
kono
parents:
diff changeset
88 (Item : aliased in out Atomic_Unsigned) with Inline_Always;
kono
parents:
diff changeset
89 -- Decrements value of atomic counter
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 -- The "+" and "-" abstract routine provided below to disable BT := BT + 1
kono
parents:
diff changeset
92 -- constructions.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function "+"
kono
parents:
diff changeset
95 (Left, Right : Atomic_Unsigned) return Atomic_Unsigned is abstract;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 function "-"
kono
parents:
diff changeset
98 (Left, Right : Atomic_Unsigned) return Atomic_Unsigned is abstract;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 private
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 type Atomic_Counter is record
kono
parents:
diff changeset
103 Value : aliased Atomic_Unsigned := 1;
kono
parents:
diff changeset
104 pragma Atomic (Value);
kono
parents:
diff changeset
105 end record;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 end System.Atomic_Counters;