From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Steve Baird <baird@adacore.com>
Subject: [Ada] Lock_Free aspect takes precedence over Ceiling_Locking locking policy
Date: Mon, 12 Sep 2022 10:19:21 +0200 [thread overview]
Message-ID: <20220912081921.GA1512875@poulhies-Precision-5550> (raw)
[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]
Allow the Lock_Free aspect of a protected type to be True (but only by
explicit specification) if Ceiling_Locking locking policy has been specified.
Clarify that the Lock_Free aspect takes precedence over the Ceiling_Locking
policy in that case.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch9.adb
(Satisfies_Lock_Free_Requirements): If Ceiling_Locking locking
policy has been specified, then either return False (if Lock_Free
was not explicitly specified) or generate a warning that ceiling
locking will not be implemented for this protected unit (if
Lock_Free was explicitly specified). Generate an error message (in
addition to returning False) if an explicit Lock_Free aspect
specification is rejected because atomic primitives are not
supported on the given target.
* doc/gnat_rm/implementation_defined_pragmas.rst: Clarify that the
Lock_Free aspect for a protected unit takes precedence over the
Ceiling_Locking locking policy in the case where both apply.
* gnat_rm.texi: Regenerate.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 3156 bytes --]
diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
--- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
+++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
@@ -3752,7 +3752,12 @@ In addition, each protected subprogram body must satisfy:
* May not dereferenced access values
* Function calls and attribute references must be static
-
+If the Lock_Free aspect is specified to be True for a protected unit
+and the Ceiling_Locking locking policy is in effect, then the run-time
+actions associated with the Ceiling_Locking locking policy (described in
+Ada RM D.3) are not performed when a protected operation of the protected
+unit is executed.
+
Pragma Loop_Invariant
=====================
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -19,7 +19,7 @@
@copying
@quotation
-GNAT Reference Manual , Aug 25, 2022
+GNAT Reference Manual , Sep 09, 2022
AdaCore
@@ -5273,6 +5273,12 @@ May not dereferenced access values
Function calls and attribute references must be static
@end itemize
+If the Lock_Free aspect is specified to be True for a protected unit
+and the Ceiling_Locking locking policy is in effect, then the run-time
+actions associated with the Ceiling_Locking locking policy (described in
+Ada RM D.3) are not performed when a protected operation of the protected
+unit is executed.
+
@node Pragma Loop_Invariant,Pragma Loop_Optimize,Pragma Lock_Free,Implementation Defined Pragmas
@anchor{gnat_rm/implementation_defined_pragmas pragma-loop-invariant}@anchor{95}
@section Pragma Loop_Invariant
diff --git a/gcc/ada/sem_ch9.adb b/gcc/ada/sem_ch9.adb
--- a/gcc/ada/sem_ch9.adb
+++ b/gcc/ada/sem_ch9.adb
@@ -651,9 +651,34 @@ package body Sem_Ch9 is
begin
if not Support_Atomic_Primitives_On_Target then
+ if Lock_Free_Given then
+ Error_Msg_N
+ ("Lock_Free aspect requires target support for "
+ & "atomic primitives", N);
+ end if;
return False;
end if;
+ -- Deal with case where Ceiling_Locking locking policy is
+ -- in effect.
+
+ if Locking_Policy = 'C' then
+ if Lock_Free_Given then
+ -- Explicit Lock_Free aspect spec overrides
+ -- Ceiling_Locking so we generate a warning.
+
+ Error_Msg_N
+ ("Lock_Free aspect specification overrides "
+ & "Ceiling_Locking locking policy??", N);
+ else
+ -- If Ceiling_Locking locking policy is in effect, then
+ -- Lock_Free can be explicitly specified but it is
+ -- never the default.
+
+ return False;
+ end if;
+ end if;
+
-- Get the number of errors detected by the compiler so far
if Lock_Free_Given then
reply other threads:[~2022-09-12 8:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220912081921.GA1512875@poulhies-Precision-5550 \
--to=poulhies@adacore.com \
--cc=baird@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).