From patchwork Wed Oct 4 17:04:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 148526 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp342319vqb; Wed, 4 Oct 2023 12:00:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIa0j7ITjr4tNbWRsB9mbTHPXBzikzNYDGucxyXzK3vafXtQbdakdxTlNhoczCdnm9bQL4 X-Received: by 2002:aa7:d451:0:b0:52f:b5c8:fa6a with SMTP id q17-20020aa7d451000000b0052fb5c8fa6amr2823948edr.20.1696446056262; Wed, 04 Oct 2023 12:00:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696446056; cv=pass; d=google.com; s=arc-20160816; b=DUMca72EtWUrLSXWiaV3UHJEqZYID5Ui7VVsZD/Rr8esMWVC0+n2HNzUtqJe3+skur XzlAH+zg0Yjd77zSDjiFKnZ3hQYSCjXv1j3oFJRuPadJOQlMA/MJrxvHAeDP97F3rkZR z5rq7dKBL4FEpPEvHOsGNGaXwgR6OzUtHmEpyHHqFxBiBtvUVQiqzxQ6Rd0M8yFr3xPr dqktNGJV1jJapqsG/S+sliTeBiNg2htgIY7NBpjoGH9Ry9WGUkVI5DGaOyWz8S0JHY6d hkTHlfgC0NT9Y7hzL4HzHc0Z101etWLz/3A0VcwCjeoR2FLG5yCqz2YksjbI0U50uH5S XaEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:date:message-id:references :content-transfer-encoding:mime-version:subject:in-reply-to:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=tkhbHM3unlyOEBdJqYQPbJgXbjbwrDVSrtMdHr3ZnUo=; fh=AKfNtHGieTaUQwRqhtuKEF5if3WVqTGfwxCWwW3MSPg=; b=b1R1z4AAYNp8YDyBMb9F62LLV3a3P7PiHtC6lmALgEWacdNY7uekeWqZ5PKAKZtzHc 3sElgsbZtRq1WQG4aiLtbZiC3NVBTQFseN6rwlee+AEWyQElKTDBF6uNXHMnaD7T6QVL SH0pZ1cOhGT8AnuqM8JXREk6gfeLi12XjYlsfFjMdPSx8r1oQGxezhWAcCWBcPiLaQiw mNWAFEv6Rnr4SxtnLHgjN+jNHAzWncdV8Hi8S5g5dW3JpZO3ZtTNjv5hP04jDokvkMdD 0Mj+PNiDUSZuWgXitc5d/77f+AQKoU3zjjmbfBaa2DSpYwbjP/4ljQEKS3xp8lXu2LPe IcTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=AywYoUji; arc=pass (i=1); 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=axis.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p23-20020aa7d317000000b00532db0a52b8si173619edq.340.2023.10.04.12.00.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:00:56 -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=@axis.com header.s=selector1 header.b=AywYoUji; arc=pass (i=1); 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=axis.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73A693882AFD for ; Wed, 4 Oct 2023 17:05:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2053.outbound.protection.outlook.com [40.107.21.53]) by sourceware.org (Postfix) with ESMTPS id 117593858C39; Wed, 4 Oct 2023 17:04:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 117593858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZ+ZICmnu2Q+PWRf+tfpoqrQvh4/f5zUqhKPZRzX8WJR4yrVDDdNlS1yC5VOq6gBf6nMHAyirwJcMRBHEdCIbDZWqMeuB+rkdukYqoEji2fxFhG/Z39M3RLolWU3HW1HJsaDI92GpWNd8MwvMEx6B7gt95EE5TWsv/OAmP5IMfrGU0CyUz5Mw/SGyO011aqohta7j6OaFrhdI1Frank5PJs47NnfS2SAwl+3X5ctx3UITlBoAdraJTS78JR4VOW3hf5k0HBuwIhPKW6NqGP5DOEaAZf3t1Bv6ivWA95r/a2T6r5MIJlfGJlhgqA5G7LYos6gow0SYF6TiEcxMVzdug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tkhbHM3unlyOEBdJqYQPbJgXbjbwrDVSrtMdHr3ZnUo=; b=VVbQuKldxWv2hJnJnXwmi3AxJmQVwoN39p2Egu+1j4WAtYCYbKPmsQ5jS/kWqFzzMIeqjWdCyfwvrf8II9QOh8qITas35KXPR/MED5kngj8Fqn574enDvt0H7vtXz5dYjBzSMngnpqKgLvXX41JvjpRe7DhkixUqf+RqdQwh0GWT15FThW8gnQN4yuTkaUCruhjrqt5jWWBOoD4uMk3Zy+6uYq6dCUWa9zjAchmkjkthIgM4TqNij5zW65b6I1VF7AqfDAZv3xr8IDUJ+Q7Nb0M0qxfNjnHA7uqcmwHEZ5N1vmqT6LZX694+QVftozBvo53cDGsKpHX4n0LXu8K6zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tkhbHM3unlyOEBdJqYQPbJgXbjbwrDVSrtMdHr3ZnUo=; b=AywYoUjimrlNmqisAKGGEIopchynrXW0G+rmPmPCzkQG5FDlgWomUCYnJAYwof3+xg0EkKXIdQx6jZG7dG3CGCnETQxgYow7CoA/tbkLcjY0VCIyH20GYGWKAwq0XxvVZZ9RIbylvlTvb0jafnbHjicYt8Cq73sfpVT2OgJpYdc= Received: from DB9PR01CA0017.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::22) by PAWPR02MB9030.eurprd02.prod.outlook.com (2603:10a6:102:336::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Wed, 4 Oct 2023 17:04:56 +0000 Received: from DU6PEPF00009529.eurprd02.prod.outlook.com (2603:10a6:10:1d8:cafe::9d) by DB9PR01CA0017.outlook.office365.com (2603:10a6:10:1d8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33 via Frontend Transport; Wed, 4 Oct 2023 17:04:56 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by DU6PEPF00009529.mail.protection.outlook.com (10.167.8.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Wed, 4 Oct 2023 17:04:56 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 4 Oct 2023 19:04:55 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 4 Oct 2023 19:04:55 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 7C630149D; Wed, 4 Oct 2023 19:04:55 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 76C1A2043D; Wed, 4 Oct 2023 19:04:55 +0200 (CEST) From: Hans-Peter Nilsson To: , CC: , In-Reply-To: <20231004151528.2ADB12043D@pchp3.se.axis.com> (message from Hans-Peter Nilsson on Wed, 4 Oct 2023 17:15:28 +0200) Subject: [PATCH v2 1/2] testsuite: Add dg-require-atomic-cmpxchg-word MIME-Version: 1.0 References: <20230926143439.B589920431@pchp3.se.axis.com> <20231004031136.8B8BA2042A@pchp3.se.axis.com> <20231004151528.2ADB12043D@pchp3.se.axis.com> Message-ID: <20231004170455.76C1A2043D@pchp3.se.axis.com> Date: Wed, 4 Oct 2023 19:04:55 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF00009529:EE_|PAWPR02MB9030:EE_ X-MS-Office365-Filtering-Correlation-Id: 733ea00a-205b-4abb-c74d-08dbc4fc08cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GV0e54X6kB1S0biwm4ut00hY/B/iaxnTDHE0D5RUzrAPImCRWVApiejd/6JbJBMrJLOYgO98z38GptL1MbrEhUjZntuDndHuJFry42WDRu56Q0jb2ux7rH9C4NKWQsBFMx78pyPaYYGyaP2QeiyLQPWiFseEKwHjaL767gHHqy9DtMKjL4YPGNkOmKpYARg9NBrRof26e015Pp8kyU8EBaCWnxwb/WIC6M0tdjpmRI98OfeD5W9M+cLUfsaSoDJtVT2x42iGWntmrB2kclkZtb4QbsVIIkxeGWZqX6ElVbfiR3Nu98k0EWz/o1jRkKCB/AWVO/99ZzaQ/1+dKVAhWmNFzDCaQxjioQ6jFLN0T93CJuaZZGT916l+Q+9dJeCEr5M7P7Ogepy8qncxJRwpEM/csDSUbsqxD/XJ7laf7Ve+AoOYYby/gNQbhBRAOR2XLYnJl/xxoTeKfPwE+ewglabBkyOq9A+HuIwx6JkNJj6uRtiLtuFKx8gha+teZocQFKt52YHwd7XR1IECsEtjQaaM9Z/YeigBoYqkVMKsmrm5E6PHtu6P0nkpkB9mm2QvrWs2xqBe9g3UXE38bV44F8fZo9CkI/i1qeWdeBQmb/UvJK7B0l7cMiq75KP14W3SLSeIoTAmgvJKNV0NWtVWaI2jJf/TMlwFYBJXW8r8cbb7nU0rRsQxDf+djkkJZTPLJDMBM+TwVAP2JIFhsl2exkRTtI8mbo1cW3KF6lFcAm2F7EdXVYshn4ybtus11jWCm6Wo45ywFhPCVcG/qHJSJw== X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(451199024)(1800799009)(82310400011)(186009)(64100799003)(46966006)(36840700001)(40470700004)(70206006)(26005)(2906002)(110136005)(70586007)(4326008)(5660300002)(8676002)(42186006)(54906003)(41300700001)(8936002)(478600001)(36860700001)(6266002)(336012)(316002)(426003)(1076003)(47076005)(83380400001)(40460700003)(356005)(81166007)(82740400003)(40480700001)(33656002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 17:04:56.0651 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 733ea00a-205b-4abb-c74d-08dbc4fc08cb X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF00009529.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR02MB9030 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778852619618649407 X-GMAIL-MSGID: 1778852619618649407 > From: Hans-Peter Nilsson > Date: Wed, 4 Oct 2023 17:15:28 +0200 > New version coming up. Using pointer-sized int instead of int, __atomic_compare_exchange instead of __atomic_exchange, renamed to atomic-cmpxchg-word from atomic-exchange, and updating a comment that already seemed reasonably well placed. Tested as with v1 1/2. Ok to commit? -- >8 -- Some targets (armv6-m) support inline atomic load and store, i.e. dg-require-thread-fence matches, but not atomic operations like compare and exchange. This directive can be used to replace uses of dg-require-thread-fence where an atomic operation is actually used. * testsuite/lib/dg-options.exp (dg-require-atomic-cmpxchg-word): New proc. * testsuite/lib/libstdc++.exp (check_v3_target_atomic_cmpxchg_word): Ditto. --- libstdc++-v3/testsuite/lib/dg-options.exp | 9 ++++++ libstdc++-v3/testsuite/lib/libstdc++.exp | 37 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 84ad0c65330b..850442b6b7c1 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -133,6 +133,15 @@ proc dg-require-thread-fence { args } { return } +proc dg-require-atomic-cmpxchg-word { args } { + if { ![ check_v3_target_atomic_cmpxchg_word ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} + proc dg-require-atomic-builtins { args } { if { ![ check_v3_target_atomic_builtins ] } { upvar dg-do-what dg-do-what diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 608056e5068e..4bedb36dc6f9 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1221,6 +1221,43 @@ proc check_v3_target_thread_fence { } { }] } +proc check_v3_target_atomic_cmpxchg_word { } { + return [check_v3_target_prop_cached et_atomic_cmpxchg_word { + global cxxflags + global DEFAULT_CXXFLAGS + + # Set up and link a C++11 test program that depends on + # atomic-compare-exchange being available for a pointer-sized + # integer. It should be sufficient as gcc can derive all + # other operations when a target implements this operation. + set src atomic_cmpxchg_word[pid].cc + + set f [open $src "w"] + puts $f " + __UINTPTR_TYPE__ i, j, k; + int main() { + __atomic_compare_exchange (&i, &j, &k, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + return 0; + }" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11" + + set lines [v3_target_compile $src /dev/null executable ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + # No error message, linking succeeded. + return 1 + } else { + verbose "check_v3_target_atomic_cmpxchg_word: compilation failed" 2 + return 0 + } + }] +} + # Return 1 if atomics_bool and atomic_int are always lock-free, 0 otherwise. proc check_v3_target_atomic_builtins { } { return [check_v3_target_prop_cached et_atomic_builtins {