From patchwork Mon Sep 12 08:19:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1140 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1780265wrt; Mon, 12 Sep 2022 01:25:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5gcUXHkHgaWpvUAqIiVfq6SU0FaoC4+lFQllc0CVxCQTrsiS2Do7GVsUkQ7yKPHr6OdmV1 X-Received: by 2002:a05:6402:241d:b0:443:39c5:808b with SMTP id t29-20020a056402241d00b0044339c5808bmr21355132eda.39.1662971126406; Mon, 12 Sep 2022 01:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662971126; cv=none; d=google.com; s=arc-20160816; b=RPHrt6aYxzDWmGXy+6ovvGzEjEZeK4B7QQm792IBam5sTNG+wmQA7WdtMYMfEjNFyW GKFEvXT/Qf3alGN/w0GOaTauvRb8NdUPfnEbHkIbMlmjGbX/Gfik2dS7jRLl8zzConG0 ovT+Tlvdnva7ZqOVxM7GLy8G/wIB3Hb7fYDfnVJl1f6cJCkL0LnH+Kz6x/2ooWlI0EY/ l6MEGWMMkvO/Tkn0lCKlj0Deu5cPq9EBpBXwoNUe7MM/2Z4E1Smel+lxuKFXlU+RaDwc XCzIo6ATCLFCZRILjkQ9dhGULJ7MHIwB+5s5n54GWBxqiEC6Hhp/tvCYVP/DcioMD8JO HDhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=szAHLujA/mUfQyNCedQPtLV7q/GRKkdqxxq6/5RaqhA=; b=JdN/HdXdbYVREPbKzcUSp7fJ5d5Bvj1F52bBdy5XClCx8dWt4KRGB/WbXpP5XFc5t/ srrUIfbRmc7rPLe+b7Wk/PL6AmjwgFbMz0P221Sq/wZpLE9uVjpDF3pUZjbW0y/UYTWN dMDoX/fKcl9GdidiXCaIz/gtOchNColPGkCo+QURSZMXKUc8m76yRKhg9LcdLwj1OXB9 +5ZK0nf9ZnA9FXi51Tj0WmFWB19cfo9M0mSdGC/fn7DYriRVqNu+A1SogOyT1BriAJcH d/JQMPIiU8SwKal6AxWCwW9v+K3q2Yr1L3jgP5PVF83WHjLdI5qMy13jWJlgNVAgX2Jm 7UWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="U1/hZTbZ"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e10-20020a056402190a00b00451bf268c67si2488944edz.315.2022.09.12.01.25.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="U1/hZTbZ"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CEA5385114E for ; Mon, 12 Sep 2022 08:22:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CEA5385114E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662970928; bh=szAHLujA/mUfQyNCedQPtLV7q/GRKkdqxxq6/5RaqhA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=U1/hZTbZgvoSxV/olfTNUmnq5h/h9rPqsdRSBfpNPnXkf9Zkp35SkKZj5bh0N7DiD 20D7vJsXM7ndS9FNQpZp3I2EO/PtkWepgrrTVri6i+LQ7R8AfCasVZZg7PwHQqnfn7 0gYWhZ0311/azZH5xX5cjmZKKDONpeWqY0H8ggSg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 2597F3851A9E for ; Mon, 12 Sep 2022 08:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2597F3851A9E Received: by mail-wr1-x429.google.com with SMTP id t14so14062001wrx.8 for ; Mon, 12 Sep 2022 01:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=szAHLujA/mUfQyNCedQPtLV7q/GRKkdqxxq6/5RaqhA=; b=ZekPsvivLA17cVttC7ltzqhKcgYHB+jdRUdKFreJn3twATs2bLj0ug2Qw3Wk/u9fpz jvvzo4RyVVWIq0qppKEJMHVBeMP/5eA1WqdiOE3KBquUAAkGz0NL49MgE0Jaz7ZeixFw 2vkZy4mLB8TkCjIruHLkv6+lwl6i1SJmcr77D48t7Y0aV8d5+aHuKhrEubCaU0UtTcaz Ge5n/I+bR98Tn+Q4r2ywFw5tpUCwaSFU8rt2dpuTVMlv4HneeNtG6YVzjHcYeQbfYrGf Yu8ZBImjMQcM2Feh9U6SkupJjT4UAyhOuLpoY6h0Slf/9wz8UVwYuaEsZQc/AKN8TVRV qMNQ== X-Gm-Message-State: ACgBeo1VAEz6nRSivh1BUbi8D6qgCInPLnOTnwnHETDauvWZmVQrZNcl jytwlz49zbr2AgEiKbjSz0acR81NVX43kw== X-Received: by 2002:adf:fb84:0:b0:21a:10f2:1661 with SMTP id a4-20020adffb84000000b0021a10f21661mr14041447wrr.2.1662970762991; Mon, 12 Sep 2022 01:19:22 -0700 (PDT) Received: from poulhies-Precision-5550 (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id l5-20020a05600c1d0500b003b477532e66sm7939420wms.2.2022.09.12.01.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:22 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:21 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Lock_Free aspect takes precedence over Ceiling_Locking locking policy Message-ID: <20220912081921.GA1512875@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Steve Baird Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743751612106280507?= X-GMAIL-MSGID: =?utf-8?q?1743751612106280507?= 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. 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