comparison gcc/ada/libgnat/s-atopri.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
4 -- -- 4 -- --
5 -- S Y S T E M . A T O M I C _ P R I M I T I V E S -- 5 -- S Y S T E M . A T O M I C _ P R I M I T I V E S --
6 -- -- 6 -- --
7 -- S p e c -- 7 -- S p e c --
8 -- -- 8 -- --
9 -- Copyright (C) 2012-2018, Free Software Foundation, Inc. -- 9 -- Copyright (C) 2012-2019, Free Software Foundation, Inc. --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
31 31
32 -- This package contains both atomic primitives defined from gcc built-in 32 -- This package contains both atomic primitives defined from gcc built-in
33 -- functions and operations used by the compiler to generate the lock-free 33 -- functions and operations used by the compiler to generate the lock-free
34 -- implementation of protected objects. 34 -- implementation of protected objects.
35 35
36 with Interfaces.C;
37
36 package System.Atomic_Primitives is 38 package System.Atomic_Primitives is
37 pragma Preelaborate; 39 pragma Pure;
38 40
39 type uint is mod 2 ** Long_Integer'Size; 41 type uint is mod 2 ** Long_Integer'Size;
40 42
41 type uint8 is mod 2**8 43 type uint8 is mod 2**8
42 with Size => 8; 44 with Size => 8;
57 Acq_Rel : constant := 4; 59 Acq_Rel : constant := 4;
58 Seq_Cst : constant := 5; 60 Seq_Cst : constant := 5;
59 Last : constant := 6; 61 Last : constant := 6;
60 62
61 subtype Mem_Model is Integer range Relaxed .. Last; 63 subtype Mem_Model is Integer range Relaxed .. Last;
64
65 type bool is new Boolean;
66 pragma Convention (C, bool);
62 67
63 ------------------------------------ 68 ------------------------------------
64 -- GCC built-in atomic primitives -- 69 -- GCC built-in atomic primitives --
65 ------------------------------------ 70 ------------------------------------
66 71
128 -- Failure_Model : Mem_Model := Seq_Cst) return Boolean; 133 -- Failure_Model : Mem_Model := Seq_Cst) return Boolean;
129 -- pragma Import (Intrinsic, 134 -- pragma Import (Intrinsic,
130 -- Atomic_Compare_Exchange_8, 135 -- Atomic_Compare_Exchange_8,
131 -- "__atomic_compare_exchange_1"); 136 -- "__atomic_compare_exchange_1");
132 137
138 function Atomic_Test_And_Set
139 (Ptr : System.Address;
140 Model : Mem_Model := Seq_Cst) return bool;
141 pragma Import (Intrinsic, Atomic_Test_And_Set, "__atomic_test_and_set");
142
143 procedure Atomic_Clear
144 (Ptr : System.Address;
145 Model : Mem_Model := Seq_Cst);
146 pragma Import (Intrinsic, Atomic_Clear, "__atomic_clear");
147
148 function Atomic_Always_Lock_Free
149 (Size : Interfaces.C.size_t;
150 Ptr : System.Address := System.Null_Address) return bool;
151 pragma Import
152 (Intrinsic, Atomic_Always_Lock_Free, "__atomic_always_lock_free");
153
133 -------------------------- 154 --------------------------
134 -- Lock-free operations -- 155 -- Lock-free operations --
135 -------------------------- 156 --------------------------
136 157
137 -- The lock-free implementation uses two atomic instructions for the 158 -- The lock-free implementation uses two atomic instructions for the