From patchwork Wed Jul 6 15:10:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=BVKP+xp2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNKv3kS6z9ryY for ; Thu, 7 Jul 2022 01:11:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C41293858436 for ; Wed, 6 Jul 2022 15:11:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C41293858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120286; bh=/OupyG+sop4wcE23EEiFaUH0H4kdXtM99v/U7mVgcyA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BVKP+xp2WSVRd1ZvnAamP81EjMHsQ9PsLqKjR/A4fR7Dllw2jI9vXhqHNlu1e0TFU C9RXyJKU3JINDh1HwavMT72MWQLV6CWSYmyJQ52NT9ZhkiFmLyTWmVEd2D/L4ONNRU 1kPB10zTnjD+csSvOxGZVFujCGUJ2iXhRTusHrW0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2063.outbound.protection.outlook.com [40.107.20.63]) by sourceware.org (Postfix) with ESMTPS id CB5C83858C20 for ; Wed, 6 Jul 2022 15:11:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB5C83858C20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ICPJY6a+AGJ+W3HNu3wFIYCYF27gfC25yZuBdJ5/RbBUBiIMIuoOBPCGwaaSg+rudZKSRIjzexYGWiHcHA9HfSedJ53bAtQLjOI4LSgqU/yaX/0UEv5blXhfu8D8RZicvtRgj89DIBLR8Rm/QYAkBXV4bnj7+FIwyeVf+m5oeNqNFU2peWkMZc/ZVcok8pdhdUsjxCjMC7YfjLFGS+h/V9dnxZBaKjgEsC/jcj5UiVl7KIvMs3REeOWaB4L6MO07JSAhODInV83AWRYhlY4yzn+TCtOLdlHOO74hB4aXhSDIAWIZ1W43uQKTZadbqXz26GGzrWbrttv0A3j4jxiRYg== ARC-Message-Signature: i=2; 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=/OupyG+sop4wcE23EEiFaUH0H4kdXtM99v/U7mVgcyA=; b=NITkptXsmvGWCG+TlvgxATfQRF3kXtGdaUBBg/zTBbrwJsielvhFEUR+prqPExciY3mu8VOtBRpecDXW864k4cGZqayCQElS6/ceX7EsFIWsrMLOkFj2p9RPpmTEzfLHhiD6IOARbH6zBRHp3Bj7hMrSS3BjfOmXscPEwGPwP3ObcpQ8947JZ8WHwzCwNpLRldeSP00Sq74nhVcLtK2pcSfawJnGk6GUVr1fSVi98bfPs6iiD/DIZlIqv2aHXRuYX/DFmyZqg0wF//f+OVOUXcb7AypobCH/kvaoIWBcvhRUaWcFat9h+abXBRXdirYlZCUYAVQfI0H9doELBji7tw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM7PR02CA0020.eurprd02.prod.outlook.com (2603:10a6:20b:100::30) by VI1PR0801MB2078.eurprd08.prod.outlook.com (2603:10a6:800:83::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:11:05 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::57) by AM7PR02CA0020.outlook.office365.com (2603:10a6:20b:100::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21 via Frontend Transport; Wed, 6 Jul 2022 15:11:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:11:04 +0000 Received: ("Tessian outbound e5f49c5d38f9:v122"); Wed, 06 Jul 2022 15:11:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8fc81aef0d31847b X-CR-MTA-TID: 64aa7808 Received: from 8b0860295aa8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2EF6E49C-C214-4687-AE1B-05EB9C6127CB.1; Wed, 06 Jul 2022 15:10:57 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8b0860295aa8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:10:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fPjDc6zvIOSBf9eRnqTeCTH2pL/BZDwWZkrfazuXc/tiNer099pSjEh70L+HWhnhYobJFWQ3NsalWoHAvXaYecNIFl45cKAs9AK0J+808EbDrBdCif6fOeNggGMa28Jpf3iMAYcBSBV8iSFKoI73zsvz68/cAeM3OhxcC0SFr2AlDabGo6ZaJkGO6ZWv84FDmYs7Tj1f9wQzQ/2xig00tzxuLnrm9A7PVnHZjlCnvewp1XhGQF8bwZvY/HJTCucaj+MgBES2SAs05Yg8liLFUuHdDru3l6qwkUIyoJitmnKiQai9kZV61qb+LJ5IEo4J50tw2yCSqUobu3xETmLTvA== 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=/OupyG+sop4wcE23EEiFaUH0H4kdXtM99v/U7mVgcyA=; b=BmgHZ+mqxD9A8Xo2UVGidY91/le69bfeQUcHIfrn8wyrHvDQQyCTAww31albCPCin+cgIhQIk/dXoDiE6glKWZjBTfvJ+li98ChRdzWPJ5w4Evydg9Hibkzo/oGAf7QomOdhNSt6SQdUoRvuGW5r6Z+ST7fRiNE2MfMDV8mq4vmzw7puF7I3cCkeunElm9K0c2hNQNlpqmGe7p5iFlf2UEXMIS/D9HsMqydOwwjvdKU8WHrPTlTJk/G4LlMn3r7ae0gs63eu+vTGqLjA+VN3naMo8yg19o3rqYTW09Yd2ix2XRB39BhK3GAJGYxZms/UT8W6dmQwx90bQozvGVzoUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM4PR0802MB2178.eurprd08.prod.outlook.com (2603:10a6:200:5a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:10:45 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:10:45 +0000 To: 'GNU C Library' Subject: [PATCH 1/7] Use atomic_exchange_release/acquire Thread-Topic: [PATCH 1/7] Use atomic_exchange_release/acquire Thread-Index: AQHYkUpT1hmC/C1AMU2s/I50D12OeA== Date: Wed, 6 Jul 2022 15:10:45 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 13a1a17a-4fee-451d-cf7b-08da5f61bee2 x-ms-traffictypediagnostic: AM4PR0802MB2178:EE_|VE1EUR03FT036:EE_|VI1PR0801MB2078:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: lQMTyL6GkrJ9hONhFliabFsJxKfdqT4kcj46QrkKpGYa2BfRyTF6PJhSIEwIxd0v6L2uMG5I+M+kvVO5sG/Hs88H5nL4FaZ1WZKEi15wt1GLHppzyLV8jzejg61tqJuBx8Gfg60qMOMbJBnYiLT0pggbsATE1XJzX0D5iXhwC+85c4EG7XqaIYZNgvhUCZIIiYTWz8PJXlRv1lSW0q8VcR2T5zJbqZklcTQM4RqleyakuhRX0hjKO/SAtc+xW3ZkkODkvxrF0pETbs2JOtt2BUR1drHpg90Ep75t8aFiNgCRTFL3gW7PXGsg3rfL4g0S5o1IkoicBtmrjw/Hj6wB6S7G84HD3A2chV7twzwlwfXGUl6NDCQVlU4cngC08kzx1exBKEdYfUQ5zUkMSjrWhgj68pQGIuoPEYM9UG50PAJkrvSeKyAskz8izNBfjjHMU4FR+nNMYs6JmiC0HOIor5nG4Zo63kmhlWbIYdCx4tFeUBh8VnjfxRMjeXPPqYk/2w5vSznNkLT5MVdaTlI1rWC4mgG3xEgKskV9ESSBDvh0NrRx5xPgbMZhxJ61FVjBjODrWSEm4DhDrzI8SBfDwRRN2MFinogyDAw6ep5qHcAnfmR8CPW9cMeSRbotNJQKJHGt/EHd04jXyi1cULA9UzSKEf32zhTshT1bbVp7DTOgtPadeJy01Uxe6K7gsgrjyyA9agFrDfG0cL7o+l+vphM8P5I9Y96Ag3ONu3qVWnZbpCqVAyiNZrO3PdeMQA+SLiHS7bHXAO3JxyrAGEg1pwnf9YGBZ+e1UuC3x8hrLR5NG8qtIkVQy5QTn/lWteJO X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(366004)(39860400002)(83380400001)(38070700005)(52536014)(9686003)(122000001)(186003)(6916009)(316002)(8936002)(5660300002)(2906002)(26005)(33656002)(41300700001)(478600001)(30864003)(91956017)(66946007)(66556008)(55016003)(76116006)(8676002)(6506007)(86362001)(7696005)(38100700002)(66476007)(71200400001)(64756008)(66446008)(579004)(559001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2178 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8f308762-8e00-4f27-d218-08da5f61b389 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FsrweShTveSx+ys8KC4Ym2OGe8My7hvpmmUerXsdFqWRlvls7MxLxLJsM7q8crgFHFK5YRhUJAnC4O+oDgTNRgvcyP34m4GzCQldiFPAyJDIQSQAIqDNRA0JelBunJQKpsCcwlGmNfAuxfytD1CIFvbkoZrSTMb3hNcX7ahmBmttVQR5ZdGQKByTMovZ1/ZahCXM5YEf2pTyWKR3URMBH+RGUBiRJbZLv6gR7Wn+K9zLdkFAWd8mlrZzI0qaqOPOAoF/wspOzhwqRzGsIXwh+rQFaTXDqWlSHw4PXd9EHlC3DaAvo7Mma1dIuyw24Mf+kH94sTp5n2FqTHtuljeZRJTSrBTml/wgXyLCrG2opgBdhx0bWutTTbLXRFzeeeiI3zsQ7A+9BN0cNW7UlYZeuWv8i73io+fTRt6DBey+mRrfnfGt8eSojf+rWouBqVjcjOV4dq5r2Pkxm/SN2hI4aq1TEL4LaZ359jDmK+xlmd8WgeuHxOZ6xZCnHf84HrGMuwPz3O4IpC8HsCBdUhGkoGNw0pXeuLZ+StLpiKcmd+koTSABwP/cG7YvYkKC7NEd1d4J0bW76O4k2BpeYQSfhjmh9x/D03esQbPQQV8vI0RdmzHfvc84LRF++F21OxlzYIdgbTlgVQ1RZ45K29ByFWIKdpWuhd92lBDZPcCCLDXYxWufaIdh1ttFYNET+nIh5PjwJ0tV43lwBmNRy8tdUWbNako9KyIwT1TtyIQuGWMsN2qHvNcyOen5WPOMq0XixJQPcEcFyDguvogY3KJbbYdiEsSEV7iBbEOH2WdMOWcsX+0cKgq1QBTuFhE/Uwdh X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(39860400002)(36840700001)(46966006)(40470700004)(83380400001)(82310400005)(52536014)(9686003)(40460700003)(186003)(6916009)(316002)(47076005)(336012)(8936002)(5660300002)(82740400003)(81166007)(356005)(2906002)(26005)(33656002)(36860700001)(41300700001)(478600001)(30864003)(55016003)(70586007)(70206006)(40480700001)(8676002)(6506007)(86362001)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:11:04.3885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13a1a17a-4fee-451d-cf7b-08da5f61bee2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2078 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Rename atomic_exchange_rel/acq to use the standard atomic_exchange_release/acquire builtins. diff --git a/assert/assert.c b/assert/assert.c index 133a183bc337075e06447e4c8e5cfba180aaf7bf..6fe29c49ca577e12ab69172df129dcdce1ed6baf 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -74,7 +74,7 @@ __assert_fail_base (const char *fmt, const char *assertion, const char *file, /* We have to free the old buffer since the application might catch the SIGABRT signal. */ - struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, buf); + struct abort_msg_s *old = atomic_exchange_acquire (&__abort_msg, buf); if (old != NULL) __munmap (old, old->size); diff --git a/hurd/hurdlock.c b/hurd/hurdlock.c index 4f3bd3e54c6b296cfdd64b549d3f2e4669decbe2..ca407bdb1e8dea8e3979a2e8eb83acad30724ce2 100644 --- a/hurd/hurdlock.c +++ b/hurd/hurdlock.c @@ -89,7 +89,7 @@ __lll_abstimed_lock (void *ptr, while (1) { - if (atomic_exchange_acq ((int *)ptr, 2) == 0) + if (atomic_exchange_acquire ((int *)ptr, 2) == 0) return 0; else if (! valid_nanoseconds (tsp->tv_nsec)) return EINVAL; diff --git a/mach/lowlevellock.h b/mach/lowlevellock.h index a4f6af4c29d80268697477fb107d99590d3fe6d3..d0adbd42e0b4ed29984d5ce86946d3d0f5fc3dc9 100644 --- a/mach/lowlevellock.h +++ b/mach/lowlevellock.h @@ -78,7 +78,7 @@ extern kern_return_t __gsync_wait_intr || atomic_compare_and_exchange_bool_acq (__iptr, 1, 0) != 0) \ while (1) \ { \ - if (atomic_exchange_acq (__iptr, 2) == 0) \ + if (atomic_exchange_acquire (__iptr, 2) == 0) \ break; \ __lll_wait (__iptr, 2, __flags); \ } \ @@ -102,7 +102,7 @@ extern kern_return_t __gsync_wait_intr #define __lll_unlock(ptr, flags) \ ({ \ int *__iptr = (int *)(ptr); \ - if (atomic_exchange_rel (__iptr, 0) == 2) \ + if (atomic_exchange_release (__iptr, 0) == 2) \ __lll_wake (__iptr, (flags)); \ (void)0; \ }) diff --git a/malloc/malloc.c b/malloc/malloc.c index c15df0dc3ae3207a24831d2291f67b532b8caefd..1b2a19c38ac4fd0af0c0b4a953ac6580101916ca 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4743,7 +4743,7 @@ static void malloc_consolidate(mstate av) maxfb = &fastbin (av, NFASTBINS - 1); fb = &fastbin (av, 0); do { - p = atomic_exchange_acq (fb, NULL); + p = atomic_exchange_acquire (fb, NULL); if (p != 0) { do { { diff --git a/manual/llio.texi b/manual/llio.texi index e55b02d8bd839827a352c751f11ad18114c32ed3..92bfd93e067ce2a782369084ed7dae099300f418 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -2538,7 +2538,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c munmap ok @c THREAD_COPY_STACK_GUARD ok @c THREAD_COPY_POINTER_GUARD ok -@c atomic_exchange_acq ok +@c atomic_exchange_acquire ok @c lll_futex_wake ok @c deallocate_stack @asulock @ascuheap @aculock @acsmem @c lll_lock (state_cache_lock) @asulock @aculock @@ -2570,7 +2570,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c atomic_increment ok @c clone ok @c atomic_decrement ok -@c atomic_exchange_acq ok +@c atomic_exchange_acquire ok @c lll_futex_wake ok @c deallocate_stack dup @c sched_setaffinity ok @@ -2590,7 +2590,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c start_thread ok @c HP_TIMING_NOW ok @c ctype_init @mtslocale -@c atomic_exchange_acq ok +@c atomic_exchange_acquire ok @c lll_futex_wake ok @c sigemptyset ok @c sigaddset ok diff --git a/manual/memory.texi b/manual/memory.texi index 5cb1dbd281006148f23cfa38c5703fb79089ba78..abc867eaebff732b2d7cc086d9f5e3430d425295 100644 --- a/manual/memory.texi +++ b/manual/memory.texi @@ -451,7 +451,7 @@ this function is in @file{stdlib.h}. @c clear_fastchunks ok @c unsorted_chunks dup ok @c fastbin dup ok -@c atomic_exchange_acq ok +@c atomic_exchange_acquire ok @c check_inuse_chunk dup ok/disabled @c chunk_at_offset dup ok @c chunksize dup ok diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 4f9d2c1a46b363d346dbc2fa0962ae196844a43a..13acf0da8f1ab41774175401a68ce28a0eb7ed30 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -96,14 +96,6 @@ do_test (void) ret = 1; } - mem = 64; - if (atomic_exchange_acq (&mem, 31) != 64 - || mem != 31) - { - puts ("atomic_exchange_acq test failed"); - ret = 1; - } - mem = 2; if (atomic_exchange_and_add (&mem, 11) != 2 || mem != 13) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 308db65cd4c148f8a119ed9025af194946aa2c80..870a8fcb34eb43b58c2260fee6a4624f0fbbd469 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -415,7 +415,7 @@ start_thread (void *arg) unwind_buf.priv.data.cleanup = NULL; /* Allow setxid from now onwards. */ - if (__glibc_unlikely (atomic_exchange_acq (&pd->setxid_futex, 0) == -2)) + if (__glibc_unlikely (atomic_exchange_acquire (&pd->setxid_futex, 0) == -2)) futex_wake (&pd->setxid_futex, 1, FUTEX_PRIVATE); if (__glibc_likely (! not_first_call)) diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index db99175dbba1cbd5e6fbdd273a0995ed8ed7920b..27c5f539a636a1530155f843aadc69ada73432f3 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -171,7 +171,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr) The unlock operation must be the last access to the mutex to not violate the mutex destruction requirements (see __lll_unlock). */ private = PTHREAD_ROBUST_MUTEX_PSHARED (mutex); - if (__glibc_unlikely ((atomic_exchange_rel (&mutex->__data.__lock, 0) + if (__glibc_unlikely ((atomic_exchange_release (&mutex->__data.__lock, 0) & FUTEX_WAITERS) != 0)) futex_wake ((unsigned int *) &mutex->__data.__lock, 1, private); diff --git a/sysdeps/aarch64/atomic-machine.h b/sysdeps/aarch64/atomic-machine.h index 52b3fb2047cbf2518644b1595ed9a11cddcc89d2..459deeec18713a374bbe186bf84b0c366896a8d7 100644 --- a/sysdeps/aarch64/atomic-machine.h +++ b/sysdeps/aarch64/atomic-machine.h @@ -103,28 +103,6 @@ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \ mem, new, old, __ATOMIC_RELEASE) - -/* Atomic exchange (without compare). */ - -# define __arch_exchange_8_int(mem, newval, model) \ - __atomic_exchange_n (mem, newval, model) - -# define __arch_exchange_16_int(mem, newval, model) \ - __atomic_exchange_n (mem, newval, model) - -# define __arch_exchange_32_int(mem, newval, model) \ - __atomic_exchange_n (mem, newval, model) - -# define __arch_exchange_64_int(mem, newval, model) \ - __atomic_exchange_n (mem, newval, model) - -# define atomic_exchange_acq(mem, value) \ - __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_ACQUIRE) - -# define atomic_exchange_rel(mem, value) \ - __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_RELEASE) - - /* Atomically add value and return the previous (unincremented) value. */ # define __arch_exchange_and_add_8_int(mem, value, model) \ diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h index 8d62b31e23d53ff2789bb32a828eac2254434679..08aa2eff891b7be32243e9955d998892807c7b2e 100644 --- a/sysdeps/aarch64/nptl/tls.h +++ b/sysdeps/aarch64/nptl/tls.h @@ -98,7 +98,7 @@ typedef struct # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h index ddf7de0705b37be20dbd7c981ff79e36659e0439..8f5b69ad3b1b0c557fa1bae55278547572a374cc 100644 --- a/sysdeps/alpha/nptl/tls.h +++ b/sysdeps/alpha/nptl/tls.h @@ -95,7 +95,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h index 15adfc94918dda2364ab5321d3a6ce5693ba4ad4..7fc6602b236fa2455f8de4a0540442ae85d27c98 100644 --- a/sysdeps/arc/nptl/tls.h +++ b/sysdeps/arc/nptl/tls.h @@ -103,7 +103,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/arm/nptl/tls.h b/sysdeps/arm/nptl/tls.h index 02d9be202d77b9ec871a52be5a4e49feffc300b1..7657ca3dccc2d929c71236d42fc060a4b4902e2b 100644 --- a/sysdeps/arm/nptl/tls.h +++ b/sysdeps/arm/nptl/tls.h @@ -89,7 +89,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h index cd135d546444e2e8f8ce0d53d5a16e2b13709bb9..58d6ab0fb2ae90de50cffd5b4a98426c6a793050 100644 --- a/sysdeps/csky/nptl/tls.h +++ b/sysdeps/csky/nptl/tls.h @@ -118,7 +118,7 @@ typedef struct # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/hppa/nptl/pthread_spin_init.c b/sysdeps/hppa/nptl/pthread_spin_init.c index aca5e01fced74695b38d94fa66026df15607be01..f2a2009daa17043541a13bb1f64b5b255c83050c 100644 --- a/sysdeps/hppa/nptl/pthread_spin_init.c +++ b/sysdeps/hppa/nptl/pthread_spin_init.c @@ -23,7 +23,7 @@ __pthread_spin_init (pthread_spinlock_t *lock, int pshared) { /* CONCURRENCTY NOTES: - The atomic_exchange_rel synchronizes-with the atomic_exhange_acq in + The atomic_exchange_release synchronizes-with the atomic_exhange_acq in pthread_spin_lock. On hppa we must not use a plain `stw` to reset the guard lock. This @@ -40,7 +40,7 @@ __pthread_spin_init (pthread_spinlock_t *lock, int pshared) Therefore if a variable is used in an atomic macro it must always be manipulated with atomic macros in order for memory ordering rules to be preserved. */ - atomic_exchange_rel (lock, 0); + atomic_exchange_release (lock, 0); return 0; } versioned_symbol (libc, __pthread_spin_init, pthread_spin_init, diff --git a/sysdeps/hppa/nptl/pthread_spin_unlock.c b/sysdeps/hppa/nptl/pthread_spin_unlock.c index 5639ec84ec3e058438f0407b3f5da4cb62de1b37..885ce2b2ba7b679a8ec06ef24d8e4cdff22c2798 100644 --- a/sysdeps/hppa/nptl/pthread_spin_unlock.c +++ b/sysdeps/hppa/nptl/pthread_spin_unlock.c @@ -23,7 +23,7 @@ __pthread_spin_unlock (pthread_spinlock_t *lock) { /* CONCURRENCTY NOTES: - The atomic_exchange_rel synchronizes-with the atomic_exhange_acq in + The atomic_exchange_release synchronizes-with the atomic_exhange_acq in pthread_spin_lock. On hppa we must not use a plain `stw` to reset the guard lock. This @@ -40,7 +40,7 @@ __pthread_spin_unlock (pthread_spinlock_t *lock) Therefore if a variable is used in an atomic macro it must always be manipulated with atomic macros in order for memory ordering rules to be preserved. */ - atomic_exchange_rel (lock, 0); + atomic_exchange_release (lock, 0); return 0; } versioned_symbol (libc, __pthread_spin_unlock, pthread_spin_unlock, diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h index 204960d524246af3e8be40ecad20ffb567f2dc6d..e6b0bd5c7182b497aaf0d2bb08f62551a223c403 100644 --- a/sysdeps/hppa/nptl/tls.h +++ b/sysdeps/hppa/nptl/tls.h @@ -123,7 +123,7 @@ static inline void __set_cr27(struct pthread *cr27) #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h index 8ccedb73e610095337b8a082ee0742866ac4e2f8..d2411b3c1ac29733c0bb3683d83388e2e0e8e277 100644 --- a/sysdeps/ia64/nptl/tls.h +++ b/sysdeps/ia64/nptl/tls.h @@ -147,7 +147,7 @@ register struct pthread *__thread_self __asm__("r13"); #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h index 30d58e36e9552d1776fffe071653c78a8012408b..742e1b6767d99fa6011ac1d207264c7b82e53787 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -122,7 +122,7 @@ extern void * __m68k_read_tp (void); #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h index 40a6acd71e710c35f2b8ef2495fdeb34906f9517..588fd1c5d63ee4e6a1b284cc19e216b6730a2091 100644 --- a/sysdeps/microblaze/nptl/tls.h +++ b/sysdeps/microblaze/nptl/tls.h @@ -100,7 +100,7 @@ typedef struct # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index 03a5b24abd5d1d6254418e79cb231b03cee72d99..2aa7cb4bb8d0b5a31889aa33d5751104ff1e4f45 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -150,7 +150,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h index 18080275ef7458c80c7826fc0fa0f6a4fadac320..cb231e2a4bbfa52495c4c017a7d3e1c6dd7937ca 100644 --- a/sysdeps/nios2/nptl/tls.h +++ b/sysdeps/nios2/nptl/tls.h @@ -130,7 +130,7 @@ register struct pthread *__thread_self __asm__("r23"); #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h index cf54c27ed9d5780cd9a9166878fdc5a204c0b64f..f64728b3988aeede7e5f29ef286abaca0d705744 100644 --- a/sysdeps/nptl/futex-internal.h +++ b/sysdeps/nptl/futex-internal.h @@ -319,7 +319,7 @@ __futex_clocklock64 (int *futex, clockid_t clockid, { if (__glibc_unlikely (atomic_compare_and_exchange_bool_acq (futex, 1, 0))) { - while (atomic_exchange_acq (futex, 2) != 0) + while (atomic_exchange_acquire (futex, 2) != 0) { int err = 0; err = __futex_abstimed_wait64 ((unsigned int *) futex, 2, clockid, diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h index b429d9aa780f3c5ca6e4ae0f8e4e31e6ef8950f2..29aa9adb89e5f6291b30b9435201d597b58cb595 100644 --- a/sysdeps/nptl/lowlevellock.h +++ b/sysdeps/nptl/lowlevellock.h @@ -119,7 +119,7 @@ libc_hidden_proto (__lll_lock_wait) ((void) \ ({ \ int *__futex = (futex); \ - if (__glibc_unlikely (atomic_exchange_acq (__futex, 2) != 0)) \ + if (__glibc_unlikely (atomic_exchange_acquire (__futex, 2) != 0)) \ __lll_lock_wait (__futex, private); \ })) #define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) @@ -147,7 +147,7 @@ libc_hidden_proto (__lll_lock_wake) ({ \ int *__futex = (futex); \ int __private = (private); \ - int __oldval = atomic_exchange_rel (__futex, 0); \ + int __oldval = atomic_exchange_release (__futex, 0); \ if (__glibc_unlikely (__oldval > 1)) \ { \ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \ diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h index c6ffe62c3f8c1ae330e6402640294cbc18714883..e82f444738de222c0e4866d5a2ab8191ce99ddc9 100644 --- a/sysdeps/or1k/nptl/tls.h +++ b/sysdeps/or1k/nptl/tls.h @@ -164,7 +164,7 @@ register tcbhead_t *__thread_self __asm__("r10"); #define THREAD_GSCOPE_RESET_FLAG() \ do \ { \ - int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,\ + int __res = atomic_exchange_release (&THREAD_SELF->header.gscope_flag,\ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, \ diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index 2ee0010b8dbee26dcc10d5cffab1b410c0446b31..b37423d681c09321e5969e81e32f88f33f675ecb 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -140,8 +140,8 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...) /* We have to free the old buffer since the application might catch the SIGABRT signal. */ - struct abort_msg_s *old = atomic_exchange_acq (&__abort_msg, - buf); + struct abort_msg_s *old = + atomic_exchange_acquire (&__abort_msg, buf); if (old != NULL) __munmap (old, old->size); } diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h index 22b00752350196ad7e6d0fbdcafdc271f0af5bed..e62a96238aa95c79ac1f749b4dbf03985b6e15d4 100644 --- a/sysdeps/powerpc/nptl/tls.h +++ b/sysdeps/powerpc/nptl/tls.h @@ -214,7 +214,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h index 4e586f348adf6556151c850e983bbcaa42a91b0f..700c2f51899b0385d7ebaa4810c84de4fa6f2b45 100644 --- a/sysdeps/riscv/nptl/tls.h +++ b/sysdeps/riscv/nptl/tls.h @@ -113,7 +113,7 @@ typedef struct # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h index 6b1de51c2a30baf5554a729a80a7ce04b56fc22c..fe7f04cf30cf5b62fea743a72384f8fc248d2d25 100644 --- a/sysdeps/s390/atomic-machine.h +++ b/sysdeps/s390/atomic-machine.h @@ -71,14 +71,6 @@ 1, __ATOMIC_ACQUIRE, \ __ATOMIC_RELAXED); }) -/* Store NEWVALUE in *MEM and return the old value. */ -#define atomic_exchange_acq(mem, newvalue) \ - ({ __atomic_check_size((mem)); \ - __atomic_exchange_n (mem, newvalue, __ATOMIC_ACQUIRE); }) -#define atomic_exchange_rel(mem, newvalue) \ - ({ __atomic_check_size((mem)); \ - __atomic_exchange_n (mem, newvalue, __ATOMIC_RELEASE); }) - /* Add VALUE to *MEM and return the old value of *MEM. */ /* The gcc builtin uses load-and-add instruction on z196 zarch and higher cpus instead of a loop with compare-and-swap instruction. */ diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h index ff210ffeb25a140bb19dbf54ab299350dc261ac7..98d7870148ce6bc1d6397b1465dfabe96f7280b2 100644 --- a/sysdeps/s390/nptl/tls.h +++ b/sysdeps/s390/nptl/tls.h @@ -157,7 +157,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h index 76591ab6ef6c12b73dda0feb18ab5adfbf53c28e..1530489a6ce4286bc5146e6cd83e3b463b965467 100644 --- a/sysdeps/sh/nptl/tls.h +++ b/sysdeps/sh/nptl/tls.h @@ -129,7 +129,7 @@ typedef struct #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h index d1e2bb4ad192cc7c825fd62b03bec45bc537aaf6..95a69cb8249dc79c3a063637a21d976d2660c48f 100644 --- a/sysdeps/sparc/nptl/tls.h +++ b/sysdeps/sparc/nptl/tls.h @@ -130,7 +130,7 @@ register struct pthread *__thread_self __asm__("%g7"); #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + = atomic_exchange_release (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index f4b2cbced828a80335887bf172fd60767cf978ac..a3eff1134ac2bed7e1e14de961cf77b8b1a33ce5 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -118,12 +118,6 @@ # define __arch_exchange_64_int(mem, newval, model) \ __atomic_exchange_n (mem, newval, model) -# define atomic_exchange_acq(mem, value) \ - __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_ACQUIRE) - -# define atomic_exchange_rel(mem, value) \ - __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_RELEASE) - /* Atomically add value and return the previous (unincremented) value. */ # define __arch_exchange_and_add_8_int(mem, value, model) \ diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index ffd059618878be42c05fb21cd51b7434a6f37637..c27a437ec1b129fc18ca832708a69627959fc107 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -95,34 +95,6 @@ #endif -/* Note that we need no lock prefix. */ -#define atomic_exchange_acq(mem, newvalue) \ - ({ __typeof (*mem) result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile ("xchgb %b0, %1" \ - : "=q" (result), "=m" (*mem) \ - : "0" (newvalue), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile ("xchgw %w0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" (newvalue), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile ("xchgl %0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" (newvalue), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile ("xchgq %q0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" ((int64_t) cast_to_integer (newvalue)), \ - "m" (*mem)); \ - else \ - { \ - result = 0; \ - __atomic_link_error (); \ - } \ - result; }) - - #define __arch_exchange_and_add_body(lock, pfx, mem, value) \ ({ __typeof (*mem) __result; \ __typeof (value) __addval = (value); \ From patchwork Wed Jul 6 15:12:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=vmOf+xkU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNMl1YPwz9ryY for ; Thu, 7 Jul 2022 01:13:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 101823858C39 for ; Wed, 6 Jul 2022 15:13:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 101823858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120385; bh=Uj0c/LGA87wMGZ35qEdh/g9e+wbAFQS2xiS+QetuKrM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vmOf+xkUHGK8Wp5uEVzdhvI4sNtCah52+S8HfERIE1M+rXFlSYeBLCyZ3DaqTKMNu TKPHrmL0cYlQPez3Caa1KGQ29fzJhvNuQ5HSI+XuVA+OL2HSFfhI7rU9N5JgH/MPDj Q+0LglcWlGfm+H6M7sju8jMmQR47xvxgQIS9IXX0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50060.outbound.protection.outlook.com [40.107.5.60]) by sourceware.org (Postfix) with ESMTPS id 99ED53858C20 for ; Wed, 6 Jul 2022 15:12:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99ED53858C20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=nS2oqNZX+dGOf36OyxZqbzhLJ7+Xr+7jSDhV0NRmoveWkFqLAR9J5UW3W6daMEQOuVmhTDF9J8k9T5WFY1KzsO2uvlww14uJoOfX+K+JMF8hpHnNn2tQOG6hgmVMEgatmrm+M4on/VQ84AV5N5ga6WH9DgDyhGbT1gh98ripp+HKhrDCPOQmCHQhN+/P1vd+18DjlmQmp8RP8rkJNZcCCmwuh5piKpmn+12qBqI+OuHfQPoCy2lE50s6r8KWRZCmCYQug38+Hwu9YnCeIALODdjVPV0Ucn/8XwtaWbrlovdD1I+xgT0GUvNjPy9onrzKn3yVmp+IgYzxtK3f/kLohA== ARC-Message-Signature: i=2; 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=Uj0c/LGA87wMGZ35qEdh/g9e+wbAFQS2xiS+QetuKrM=; b=BOgbpVWjb6i+fQOVGRbyq0NiKetPuWSKBFRnnIVnP5iHRb7PDysIsBkhRmnfoygyrmdx7cPqCN4hZSxTiIObT4yMOW6JDpPUXU2wPem8CqYjRHurC/1RSzYFM5UEt4FW3alA3UmZ6KW430lFHUz3j5c+SoBB1lTnJfsV5l4T2Tb+DG2Oum2wE7vXruXqFFY70z+zW5VUu0jenNDnVkqUJUtIRAL8Zts8EQuAH7l/d8N/2y7bIlnvp3kAyOnd1tLc9YvtwkWCn4r5a0RS7prOdPjGWqAK2XM99EXWSYpbmFlBbUFwKUPk5/Gyt+9sYPoDiy2/1wlbe4Qr+tjCbSPXOw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB6PR07CA0103.eurprd07.prod.outlook.com (2603:10a6:6:2c::17) by DB9PR08MB6811.eurprd08.prod.outlook.com (2603:10a6:10:2a7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Wed, 6 Jul 2022 15:12:45 +0000 Received: from DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::fc) by DB6PR07CA0103.outlook.office365.com (2603:10a6:6:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.6 via Frontend Transport; Wed, 6 Jul 2022 15:12:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT026.mail.protection.outlook.com (100.127.142.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:12:44 +0000 Received: ("Tessian outbound 190453a6d737:v122"); Wed, 06 Jul 2022 15:12:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dd1c9470880934c4 X-CR-MTA-TID: 64aa7808 Received: from ac253347ce27.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 86917B28-BAC2-4429-9E95-6B5377861D5B.1; Wed, 06 Jul 2022 15:12:37 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ac253347ce27.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:12:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PAEtLN7SOy/8FHDN7JnjhTDjYFev4uiztbRm/z1BFOSCvLOTClUDvohhfrzhRIvTc2WyCdXtp97dYlItsQPwWlDGgXSuQE2wLyOPIMW7i4YjL6QJbe+ezYAR5MQ9Klh1DeTgskVlGxKQc3DLsYSm9GVQwM+1QVGnZpXhyClROG5OJEG9mRtI9AQy8x1zOo6ZnNciqkMtrR0Mq+41QCp/to89tKhQo0BbQBLAiTFgH9tRgl3+pp+FLFT0pIh3ECYLJ1e+31ckMIV4Bns6JsTf1dYzwjNuyGJT44mlfvmiKuIHDzFzM2SQVN0zfIwV2jfspnJVJLD09EBNAXkpfhjxxQ== 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=Uj0c/LGA87wMGZ35qEdh/g9e+wbAFQS2xiS+QetuKrM=; b=Df/iKDdkKqm3qRgsYlSWZbzW3DpRU4RZhgcelxDb41kWfNYbnAz2OLSE9jDHFP59xda+wdu8uJxGg+XyvXPSWKFIeBKtZwvhxKPQv0WVXLnMTGh9aTsTPc+zWHaVEjdcQHJFPvZvfR5nCBF4FgisaB+pH1bYaU1sBT0uDwRkOleBF3XtvTX0L2UucHdoS4sutaIsIbRYs+aLV3cdXecRDQtUyIeVpWwoaoMf8hnjzlrD/bGv2MTEwiXv5qzrI3pvAvLhwpp7qsFEclJJKaIwk1fBqqcLjLVdfPOCidDuuo0xNg7P15RoCSZPt0jp7WGXVbnqEklYrziPdXKmrvSj1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM4PR0802MB2178.eurprd08.prod.outlook.com (2603:10a6:200:5a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:12:35 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:12:35 +0000 To: 'GNU C Library' Subject: [PATCH 2/7] Use atomic_max_relaxed Thread-Topic: [PATCH 2/7] Use atomic_max_relaxed Thread-Index: AQHYkUqtlJgSkjccBUC5Yv+bdre4LA== Date: Wed, 6 Jul 2022 15:12:35 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: c49273fe-80b2-4dae-ee7e-08da5f61fac4 x-ms-traffictypediagnostic: AM4PR0802MB2178:EE_|DBAEUR03FT026:EE_|DB9PR08MB6811:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ZfucYfvxPeKHsqGF0866mHYOqOGwOCLt6JVNuJl04F+AJntTZFwfEEsF4g/l0jhZAN2nTGnxrvExuVcJ+TNpEeYibHYTnsNhi4SwOkRWAb71qU0nJo3KEd3HH4aY3eaXUC++jtGAdWoXxHQvi0xH5CWlnqerIvPKuYdNdqXucvkxNSvCJ6i1QaYoF4VpUjgUdBbXNngfl+8Gm82s6HZvGLArA2gFq/kxreMIXPiUG4POJYe1bwfDOlC5N6wwsqx/HzoBSHeTWR8RNyf/ZK9j4vP+rZuhX2gl6hPhBLdZsz+7AZVzoEsDT8s08O+3/RjKU8nKmgU+gW35kd76KMXQRJJwR6/dtlRb1hRYaev13W5UK+t04ThFxdunE8VltAu68uMJpQIt5ULT8rT5MjWY8dFM9wloVJc74mr0uqRdMrjtx2bUPAi/NGdaxAztesWkK/OLzhpiD6LraT8omCjs6UA8qonJd4uOngz/pjSSCOxJzTPU+h9neTSYl2E5k2pIoVHSoqwVLPiLglbxdLXG9pWSl00s0memo+Mi4cBaM9ubOGceUf2SWpk3189JDuK57wDrOAmHnlKKZruXFi4tjomZ+/JzzSPwobLEmN6pxo9k2NIkR7vzRpWiyRTRw/2OKxOmQUneljXDBYmNymqrcq+KaQRHvjpa26c62QVvSEz4hkhD8WXMs7TWJRV8fYIhq8X9JblapUHGO3ghS0xGu0QHTJSdUpuuykqz943FBiVev8VR7sV76no+OFxf0Q6bV8qcRaTBB5B7b6Od6a5XY2lv2PgkpCoxJl1W/IaagbWqvMlV8aAxZT+2NaM1nXf7 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(366004)(39860400002)(83380400001)(38070700005)(52536014)(9686003)(122000001)(186003)(6916009)(316002)(8936002)(5660300002)(2906002)(26005)(33656002)(41300700001)(478600001)(91956017)(66946007)(66556008)(55016003)(76116006)(8676002)(6506007)(86362001)(7696005)(38100700002)(66476007)(71200400001)(64756008)(66446008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2178 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6d61d629-fb93-4f46-7ad1-08da5f61f4e9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0HSAre1lBOLLNSrbigJJ+2xV6tpxg5mj/ymlnx2iaQC1RjCzY8hPbP4wZwehH1R7aeOBw+Yd+eZjvJwJc6tolqsAJNenQKsonCXW6XFnzUCJNmOLSKA98jpSV6YC6GUVIq2hwpQVPOEn6AeWRp90UeiVB8mspdnTd8iHZAQydICIkXcBTCxFYZ214SouC2E2hvV5jo8wFuoZX1yuOMuFDWYk/kac4gs90XjPkht6/IxPBcN3U8d2v9sepKhIQ64n9mGY72CZoQcvFeurPhGF2/mzp262tMnDQb+v0YYikL4CF3zIvH+TVcI+0jbfO0FxEJROJt3dSGkxB1Mxn37CCpNKNynRPYfpezLsPeejqumYoHsLJAiT1J80Jp2EM3IczYRfgrTKUGYxlntaUv5UldsMRZj9piKNYSzznfdCgO5vwnUQtWQIA0P4KrydhufilXt7/AX4bDwEbDFYxYfHfeFq2GhdXYvxrOJQdvIqOuj0OE4oz+evtjcQBBPovyQhYFCjiIis64WtwVtdI6OoRTQaDrRZqS/jzWxQPUbXesaEbgutA6fRjVpPrRmaVybFxLy7LCSqAEnPW6nY3rT7sFWX3asmox4Kw/BCtIM54TWDsVlwzZ8PYB7TFJQBw/kQVeg8EnL80FqTeYlj/skcXIV2FiRNn7CPzu1mf2SuoiYM7M0pnn20I9W+osY/JLgqN8nbXPMCmMNPF6Gc1aFUD04orpXb3lCb78ewrtaiqF3buThFbvpUJyhL4GY7jsp+qtOxyrgv0m6UOw78Emc8btLKykZej23d/+6TsVKZRM8o0dLW2qZ8w42+AcEXAg8t X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(346002)(136003)(376002)(39860400002)(396003)(46966006)(40470700004)(36840700001)(7696005)(26005)(6506007)(40460700003)(9686003)(47076005)(186003)(82740400003)(83380400001)(336012)(478600001)(40480700001)(2906002)(33656002)(55016003)(8676002)(70206006)(70586007)(41300700001)(86362001)(82310400005)(8936002)(81166007)(52536014)(5660300002)(36860700001)(6916009)(316002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:12:44.9866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c49273fe-80b2-4dae-ee7e-08da5f61fac4 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6811 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Rename atomic_max to atomic_max_relaxed since it cannot guarantee a stricter memory ordering. diff --git a/include/atomic.h b/include/atomic.h index 264db9a0b7619ff6520f84a19c53c1eb9a3b42a3..73cc772f0149f94fa0c3e14fa858fa89fee6985f 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -165,14 +165,15 @@ atomic_exchange_and_add_acq(mem, value) #endif -#ifndef atomic_max -# define atomic_max(mem, value) \ +#ifndef atomic_max_relaxed +# define atomic_max_relaxed(mem, value) \ do { \ __typeof (*(mem)) __atg8_oldval; \ __typeof (mem) __atg8_memp = (mem); \ __typeof (*(mem)) __atg8_value = (value); \ do { \ __atg8_oldval = *__atg8_memp; \ + /* This early-exit means the atomic has relaxed memory ordering. */ \ if (__atg8_oldval >= __atg8_value) \ break; \ } while (__builtin_expect \ @@ -181,24 +182,6 @@ } while (0) #endif -#ifndef atomic_min -# define atomic_min(mem, value) \ - do { \ - __typeof (*(mem)) __atg10_oldval; \ - __typeof (mem) __atg10_memp = (mem); \ - __typeof (*(mem)) __atg10_value = (value); \ - do { \ - __atg10_oldval = *__atg10_memp; \ - if (__atg10_oldval <= __atg10_value) \ - break; \ - } while (__builtin_expect \ - (atomic_compare_and_exchange_bool_acq (__atg10_memp, \ - __atg10_value, \ - __atg10_oldval), 0)); \ - } while (0) -#endif - - #ifndef atomic_add # define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value)) #endif diff --git a/malloc/malloc.c b/malloc/malloc.c index 1b2a19c38ac4fd0af0c0b4a953ac6580101916ca..a5e68a34059b18e67899aeb616976682382976ba 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2486,11 +2486,11 @@ sysmalloc_mmap (INTERNAL_SIZE_T nb, size_t pagesize, int extra_flags, mstate av) /* update statistics */ int new = atomic_fetch_add_relaxed (&mp_.n_mmaps, 1) + 1; - atomic_max (&mp_.max_n_mmaps, new); + atomic_max_relaxed (&mp_.max_n_mmaps, new); unsigned long sum; sum = atomic_fetch_add_relaxed (&mp_.mmapped_mem, size) + size; - atomic_max (&mp_.max_mmapped_mem, sum); + atomic_max_relaxed (&mp_.max_mmapped_mem, sum); check_chunk (av, p); @@ -3111,7 +3111,7 @@ mremap_chunk (mchunkptr p, size_t new_size) INTERNAL_SIZE_T new; new = atomic_fetch_add_relaxed (&mp_.mmapped_mem, new_size - size - offset) + new_size - size - offset; - atomic_max (&mp_.max_mmapped_mem, new); + atomic_max_relaxed (&mp_.max_mmapped_mem, new); return p; } #endif /* HAVE_MREMAP */ diff --git a/malloc/memusage.c b/malloc/memusage.c index 74712834fa8b96fb2d9589d34b34ab07d05a84ca..d2f768b97df4e383a41b0eeaf0c37433ce890757 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -149,7 +149,7 @@ update_data (struct header *result, size_t len, size_t old_len) /* Compute current heap usage and compare it with the maximum value. */ size_t heap = atomic_fetch_add_relaxed (¤t_heap, len - old_len) + len - old_len; - atomic_max (&peak_heap, heap); + atomic_max_relaxed (&peak_heap, heap); /* Compute current stack usage and compare it with the maximum value. The base stack pointer might not be set if this is not @@ -172,10 +172,10 @@ update_data (struct header *result, size_t len, size_t old_len) start_sp = sp; size_t current_stack = start_sp - sp; #endif - atomic_max (&peak_stack, current_stack); + atomic_max_relaxed (&peak_stack, current_stack); /* Add up heap and stack usage and compare it with the maximum value. */ - atomic_max (&peak_total, heap + current_stack); + atomic_max_relaxed (&peak_total, heap + current_stack); /* Store the value only if we are writing to a file. */ if (fd != -1) diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index a3eff1134ac2bed7e1e14de961cf77b8b1a33ce5..deb6cadaa35e841e23cee55d169a20538bdb1f8d 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -157,8 +157,7 @@ abort (); \ __tmp; }) -# define atomic_max(mem, value) asm_amo ("amomaxu", ".aq", mem, value) -# define atomic_min(mem, value) asm_amo ("amominu", ".aq", mem, value) +# define atomic_max_relaxed(mem, value) asm_amo ("amomaxu", "", mem, value) # define atomic_bit_test_set(mem, bit) \ ({ typeof (*mem) __mask = (typeof (*mem))1 << (bit); \ From patchwork Wed Jul 6 15:14:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=tVL8Gg+1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNPY4ygpz9ryY for ; Thu, 7 Jul 2022 01:14:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E8323858408 for ; Wed, 6 Jul 2022 15:14:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E8323858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120476; bh=f0qhG0reXaJLTdX/zeAxYms+EIbzsMwab76Uoihi6m4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tVL8Gg+10dlQ5nb+cQwpJdPOjuCY6Q6cEtG8mkprq+8pTUYHpFRwGLyMbdvc8PGBA OsYjs+zZiBCR6LqA0EK5N6Y2K1dCdEvbYuJOHF4fL5L5T9SPIUjF52qOn4MndUpePG 4Rohudda+3XhNNrntlmNrFFoyHGGoTQpy0wjoXUg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50065.outbound.protection.outlook.com [40.107.5.65]) by sourceware.org (Postfix) with ESMTPS id D8DEF3858C20 for ; Wed, 6 Jul 2022 15:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8DEF3858C20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=lzbA7zoltjVzbkW+IOhkFxD+OG0r3OL1IfytxavUkGOSs4XJlgWhwUTdhDjFG7+AQIvr0IIyUyIE0N9+Gk9NclAMwY85d6h4hLN+6WFttlUEKkTQ05wosjTTeT3REk26qVjzKV1cMrbfl0zFGCWDLs8JGDrWisvMDZyogOWg8icjD2A2XfXZkE9sawgSCzK3MER2ZIEa0GBndRt2v4zNGMiXStgQDgQyGaR7J/eaLhWR32f8JMlWhkkbtU+mY9FD8Cs0OqzL0Iq3R6x5DVpWVkaBy4vbScyyjP64W2fwegJdKBJeoTL5KKgCCluUh6u8p2eQC/h3Uo5/WOU0w9bWyw== ARC-Message-Signature: i=2; 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=f0qhG0reXaJLTdX/zeAxYms+EIbzsMwab76Uoihi6m4=; b=jsjTQTJ5iO1Y73coetRX7cgwswaRmMmGHFRdxf+lKlWpWyqnFY2DN19PscemQQtXdJ/UvurxXt/vgB1KpDfvRqxzCgOOkMvbkQuGPsm1P7yauZm+fBIwwGu5Zlt2NQW5PzYVm7xHpZc4TTwsvxLBSDtDJEBBE81fbf/P3eXzpaR/Lf89mRXyPzArvR/vKnXc6MhSYlmZvl+VWNnVK+Nykh2zGe62T6bSkIdoN1t+X40rSPyy/aHJ0Er3/ojV6uMjroH3rO9PCWMnMddw6UiJ4mza9jPVgenA7DMDiIO4h1AM/zZenN7T9rvFU/RcJa5Qr4vjLHEBm40OJg6WF41fZw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM6PR04CA0019.eurprd04.prod.outlook.com (2603:10a6:20b:92::32) by AM6PR08MB4327.eurprd08.prod.outlook.com (2603:10a6:20b:ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.17; Wed, 6 Jul 2022 15:14:15 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:92:cafe::c9) by AM6PR04CA0019.outlook.office365.com (2603:10a6:20b:92::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.22 via Frontend Transport; Wed, 6 Jul 2022 15:14:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:14:12 +0000 Received: ("Tessian outbound 0ba541f03a2a:v122"); Wed, 06 Jul 2022 15:14:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b77a2168f14af835 X-CR-MTA-TID: 64aa7808 Received: from 752ea972e0fa.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A01EEC5-9DBA-499C-AC8C-62160F717D65.1; Wed, 06 Jul 2022 15:14:05 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 752ea972e0fa.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:14:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CofBsvbECq/ITgj7MYgFCx3DbELlxYO5LW27XobN67fs5rcysRwvdfOc8otMIC0/jb8MfJPDPsvpQeHnbefFXH+Ttw93VncRZWlToP6TVMgQ36H5X3dYh+zB7vvnNS1CUsrzMZwO3A1gW4DAVSZfWNE10Qdis0B0+sW2EDdnNoEp5i2Iu3IhnRDVl5w8dPZMYB5eWgu0KuQQvJg2hy1qKPRU8MsGZ2SeWfmKtbABG92ZTdWYVQIhxFnGaOTpKArpf0V/j6EsoJhobeg5sXIGRoNo+uE+p9FcVtonU++XtviWYyJGese0N0VhGtNpupgfKMwAXiG1fmVUlMiT0qkhOA== 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=f0qhG0reXaJLTdX/zeAxYms+EIbzsMwab76Uoihi6m4=; b=nC1NhT+raz3HF12nFD5tdhJtosn9zsrHPWWhC75TnO5mo2O7lP6Cemn9kSKferwnELkD4/7W+zJdgLW6TxUWkf1b5XHCEDBKuWsAc9AEFI+woGALHYlVl1oo+hDI1SrC2EHe3Sj/e84ZSA0FjVV7STFogvh1Op9dpB6kOJ94E8LP4GsjWc3CIlWABOlZhcWXORGVpuzY2NMSLrP/l9jaKDMPyogDMTjTPvDK7UQGUtOsDA9gViuvSIYmWw7dewbaysC6gNqCFRB1QyFycfJn7ox1sCcKv3pJEsIV95qwIoc413OR5776y7tKHPh5NH9iTgTUa8ZZp4U4VagseaFiTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM4PR0802MB2178.eurprd08.prod.outlook.com (2603:10a6:200:5a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:14:03 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:14:03 +0000 To: 'GNU C Library' Subject: [PATCH 3/7] Remove atomic_bit_set/bit_test_set Thread-Topic: [PATCH 3/7] Remove atomic_bit_set/bit_test_set Thread-Index: AQHYkUrot9wGWG5wTUWQh2iJcYWu/A== Date: Wed, 6 Jul 2022 15:14:03 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: b3824250-c5af-41bd-9eb7-08da5f622f40 x-ms-traffictypediagnostic: AM4PR0802MB2178:EE_|AM5EUR03FT041:EE_|AM6PR08MB4327:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xqRpij/ygfOoY3k1URKbBedDKGrqN3pNrR0s6gj+gfKyAtrQQ42fk+uOZLjPIm03ZDcg/eqJC5fpR6DMHsliTUPuc67dFCZoY7yIKXXK/+t2jM13rX8F0k34UVtn63vDe7QLxhTD9CkTY+M0zkvTakkZDmXjGKA+XDiRiW5dJdozXobpthbQozr7btRVS1w47KD9FGJlrgsRTuI+pCe1IvbLXnFUpz+uRyVGxjlWg3MtNSWkb2PgG9zzJ2mzssDHm/WATQi5dTRi7KTQZd4jpyMiOZFsXyN+fmOnkkHqXnQFmKMmVoD5gLckdh1rpfB8nsFggN3KvAOWPW4C/zNZQF+tWNsaKRf6pTLsUF2Y9d+JQWcfmE+k+A+chO1s5IvoPRLwEf8ngVVEI0Lu8EJE9pbNZJx+yN08+Y3p5K372hoCMFGdFsoGPUz7o6N2PMIPZaYagchO/IrdbqPKDHzekJncghRemkip/M9iCoA36PBhg2tr1KubADGfyLYByakCz1aiLGofj/8O6OFsv2ssDLUkAIpSzAMMi/7pxSxMeUUqZBqO1gwYWIsL4mU1YO4/CD1hN397+880C+VHjOp4utQ7MGyt1rKn5LfDMgrwZcf80/Ka9NSjX+3EhfLklCiOgjUJhqUyggpaWFLQZb5ABx87aYTucyl3otzEneTTUMH03PC7Heql/R4Y5LZWeQUR0NfPpe916DXaBJvqP50YNzQuVqIpmg7lv6LueVUHcOTNneqMLz+vp/HSm8pfG4WofvZET52fR/Vrm2JaBmo4keQjF/ku9GD7+ir9ORI0U3LxgAOBi9cFoZnpI3lLaYDH X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(366004)(39860400002)(83380400001)(38070700005)(52536014)(9686003)(122000001)(186003)(6916009)(316002)(8936002)(5660300002)(2906002)(26005)(33656002)(41300700001)(478600001)(30864003)(91956017)(66946007)(66556008)(55016003)(76116006)(8676002)(6506007)(86362001)(7696005)(38100700002)(66476007)(71200400001)(64756008)(66446008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2178 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f15acb74-7d1f-4968-9c05-08da5f622971 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EfOzdq59kacJ62Y4nJ2P5LOqdWY4o3AcnAMW3qhId/ayAW/yDTeXMNnSyAk68lkZ3TizR3v3aqnWgA+kszhCbv9otMHB5vyJaJY1uodWzstw7DV641NuDeixBqpYP1KFdOn7xOZa1eNtNlIQz6AYEDm44Stt+VLBHOaxMW4w+JbEklpo3aCoB4fwfo5yGi4kEpiW0ewd40Z4jQ0ANGVSODVPPRMJL+YSgDnEn76eW/+fdOIgA5y5tuo4AS9QPanDnHhbAIbbVj/410zkPqP5lggTV74WXZvR3yUCScMo2ojs5JRyExa0nXOvgkollg+8kcDEuKmFzJsoOFgvch8t5iT9WdCe75nRAJ68x22KgWU2lgODMdJUsqQAqZN0Io02sZDm+5Gc9Q/D+2utddv1BRI7NLxmu3iSOo9t11+XFg6BQLurC0JAUN6m7MVEQwOahxQWtdqBS8OA/jYIAcd6CJvXAPqblCC44wYfep6dPfx5lg4z76tNOeOylLYMKL0oP4/F2C+nDBtD7qFwnbhNuxJXyXqKOJF7oX43gun08RLsqP1EJ1++ig9//ZxtzpZy1hAkvfMM4Yhw/VUTmKIWsGEDw/x05c+SN1uwK1qyIOZ6IIdSYYdxijeGfZOgJiwKYmNmiv+MTeqH5jbxa39nKyC7Ay+seTByh1dhBOs+PsoKGZvNBtiT719TkO7ykDkB73fgqRAQmAA1PGEpApwCnCDmAYkTwjL/5L3++74B8NbhYeCE0mHsH/E3NNsMZ0YwDLK9E8H0G/N2ZHLk/qECAdC0Kl3UVlnNQcTTeYz/vNpnSMKP1easzMLzI+eo+iam X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(346002)(39860400002)(396003)(376002)(136003)(40470700004)(36840700001)(46966006)(36860700001)(8676002)(70586007)(70206006)(41300700001)(86362001)(6506007)(7696005)(2906002)(478600001)(40480700001)(356005)(82740400003)(55016003)(5660300002)(33656002)(83380400001)(8936002)(40460700003)(52536014)(26005)(81166007)(9686003)(30864003)(82310400005)(47076005)(336012)(186003)(316002)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:14:12.9835 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3824250-c5af-41bd-9eb7-08da5f622f40 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4327 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Replace the 3 uses of atomic_bit_set and atomic_bit_test_set with atomic_fetch_or_acquire. This enables removal of a lot of target specific implementations. diff --git a/include/atomic.h b/include/atomic.h index 73cc772f0149f94fa0c3e14fa858fa89fee6985f..ed1fc38e7569fcbdd0473ab6f69956a44d62354f 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -255,28 +255,6 @@ #endif -#ifndef atomic_bit_set -# define atomic_bit_set(mem, bit) \ - (void) atomic_bit_test_set(mem, bit) -#endif - - -#ifndef atomic_bit_test_set -# define atomic_bit_test_set(mem, bit) \ - ({ __typeof (*(mem)) __atg14_old; \ - __typeof (mem) __atg14_memp = (mem); \ - __typeof (*(mem)) __atg14_mask = ((__typeof (*(mem))) 1 << (bit)); \ - \ - do \ - __atg14_old = (*__atg14_memp); \ - while (__builtin_expect \ - (atomic_compare_and_exchange_bool_acq (__atg14_memp, \ - __atg14_old | __atg14_mask,\ - __atg14_old), 0)); \ - \ - __atg14_old & __atg14_mask; }) -#endif - /* Atomically *mem &= mask. */ #ifndef atomic_and # define atomic_and(mem, mask) \ diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 13acf0da8f1ab41774175401a68ce28a0eb7ed30..765b036873e181d6c49299c0ad08d5dbfcc05387 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -325,66 +325,6 @@ do_test (void) ret = 1; } - mem = 0; - atomic_bit_set (&mem, 1); - if (mem != 2) - { - puts ("atomic_bit_set test 1 failed"); - ret = 1; - } - - mem = 8; - atomic_bit_set (&mem, 3); - if (mem != 8) - { - puts ("atomic_bit_set test 2 failed"); - ret = 1; - } - -#ifdef TEST_ATOMIC64 - mem = 16; - atomic_bit_set (&mem, 35); - if (mem != 0x800000010LL) - { - puts ("atomic_bit_set test 3 failed"); - ret = 1; - } -#endif - - mem = 0; - if (atomic_bit_test_set (&mem, 1) - || mem != 2) - { - puts ("atomic_bit_test_set test 1 failed"); - ret = 1; - } - - mem = 8; - if (! atomic_bit_test_set (&mem, 3) - || mem != 8) - { - puts ("atomic_bit_test_set test 2 failed"); - ret = 1; - } - -#ifdef TEST_ATOMIC64 - mem = 16; - if (atomic_bit_test_set (&mem, 35) - || mem != 0x800000010LL) - { - puts ("atomic_bit_test_set test 3 failed"); - ret = 1; - } - - mem = 0x100000000LL; - if (! atomic_bit_test_set (&mem, 32) - || mem != 0x100000000LL) - { - puts ("atomic_bit_test_set test 4 failed"); - ret = 1; - } -#endif - /* Tests for C11-like atomics. */ mem = 11; if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11) diff --git a/nptl/nptl_free_tcb.c b/nptl/nptl_free_tcb.c index 0d31143ac849de6398e06c399b94813ae57dcff3..b63ec3bc3c1df4a1fc5272a24d453e679dbedd5e 100644 --- a/nptl/nptl_free_tcb.c +++ b/nptl/nptl_free_tcb.c @@ -24,7 +24,8 @@ void __nptl_free_tcb (struct pthread *pd) { /* The thread is exiting now. */ - if (atomic_bit_test_set (&pd->cancelhandling, TERMINATED_BIT) == 0) + if ((atomic_fetch_or_acquire (&pd->cancelhandling, 1 << TERMINATED_BIT) + & (1 << TERMINATED_BIT)) == 0) { /* Free TPP data. */ if (pd->tpp != NULL) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 870a8fcb34eb43b58c2260fee6a4624f0fbbd469..4b7f3edc384748f300ca935ad878eb0e3547e163 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -487,7 +487,7 @@ start_thread (void *arg) /* The thread is exiting now. Don't set this bit until after we've hit the event-reporting breakpoint, so that td_thr_get_info on us while at the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */ - atomic_bit_set (&pd->cancelhandling, EXITING_BIT); + atomic_fetch_or_acquire (&pd->cancelhandling, 1 << EXITING_BIT); if (__glibc_unlikely (atomic_decrement_and_test (&__nptl_nthreads))) /* This was the last thread. */ diff --git a/sysdeps/alpha/atomic-machine.h b/sysdeps/alpha/atomic-machine.h index df28b90261aa485125d951bc1abf76602730bfd0..115a9df5d77cd08bcb0a49d9b59f0c53b4a20d78 100644 --- a/sysdeps/alpha/atomic-machine.h +++ b/sysdeps/alpha/atomic-machine.h @@ -325,15 +325,6 @@ #define atomic_exchange_and_add(mem, value) \ __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, __MB, __MB) - -/* ??? Blah, I'm lazy. Implement these later. Can do better than the - compare-and-exchange loop provided by generic code. - -#define atomic_decrement_if_positive(mem) -#define atomic_bit_test_set(mem, bit) - -*/ - #define atomic_full_barrier() __asm ("mb" : : : "memory"); #define atomic_read_barrier() __asm ("mb" : : : "memory"); #define atomic_write_barrier() __asm ("wmb" : : : "memory"); diff --git a/sysdeps/ia64/atomic-machine.h b/sysdeps/ia64/atomic-machine.h index 71afcfe0d0031a6ceae5879a2b3b19ed2ee2f110..b2f5d2f4774cc2503c7595cb82f30f60fbcbe89c 100644 --- a/sysdeps/ia64/atomic-machine.h +++ b/sysdeps/ia64/atomic-machine.h @@ -77,20 +77,4 @@ while (__builtin_expect (__val != __oldval, 0)); \ __oldval; }) -#define atomic_bit_test_set(mem, bit) \ - ({ __typeof (*mem) __oldval, __val; \ - __typeof (mem) __memp = (mem); \ - __typeof (*mem) __mask = ((__typeof (*mem)) 1 << (bit)); \ - \ - __val = (*__memp); \ - do \ - { \ - __oldval = __val; \ - __val = atomic_compare_and_exchange_val_acq (__memp, \ - __oldval | __mask, \ - __oldval); \ - } \ - while (__builtin_expect (__val != __oldval, 0)); \ - __oldval & __mask; }) - #define atomic_full_barrier() __sync_synchronize () diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h index 70cda007341b49d28dc1d9847a88198b47589db4..72a3b81642c1a23207054092d16bb856556cd897 100644 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h @@ -218,15 +218,3 @@ : "memory"); \ } \ __result; }) - -#define atomic_bit_set(mem, bit) \ - __asm __volatile ("bfset %0{%1,#1}" \ - : "+m" (*(mem)) \ - : "di" (sizeof (*(mem)) * 8 - (bit) - 1)) - -#define atomic_bit_test_set(mem, bit) \ - ({ char __result; \ - __asm __volatile ("bfset %1{%2,#1}; sne %0" \ - : "=dm" (__result), "+m" (*(mem)) \ - : "di" (sizeof (*(mem)) * 8 - (bit) - 1)); \ - __result; }) diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h index 39af275c254ef3e737736bd5c38099bada8746d6..e8bd4c6dcbf7b7785857ff08c15dac9a5cfb2a5d 100644 --- a/sysdeps/nptl/pthreadP.h +++ b/sysdeps/nptl/pthreadP.h @@ -43,12 +43,6 @@ atomic_compare_and_exchange_val_acq (&(descr)->member, new, old) #endif -#ifndef THREAD_ATOMIC_BIT_SET -# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ - atomic_bit_set (&(descr)->member, bit) -#endif - - static inline short max_adaptive_count (void) { #if HAVE_TUNABLES @@ -276,7 +270,7 @@ __do_cancel (void) struct pthread *self = THREAD_SELF; /* Make sure we get no more cancellations. */ - atomic_bit_set (&self->cancelhandling, EXITING_BIT); + atomic_fetch_or_acquire (&self->cancelhandling, 1 << EXITING_BIT); __pthread_unwind ((__pthread_unwind_buf_t *) THREAD_GETMEM (self, cleanup_jmp_buf)); diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h index fe7f04cf30cf5b62fea743a72384f8fc248d2d25..db31e377970c4ab6285ef65fb21419db7c6ca373 100644 --- a/sysdeps/s390/atomic-machine.h +++ b/sysdeps/s390/atomic-machine.h @@ -93,17 +93,6 @@ atomic_or_val (mem, mask); \ } while (0) -/* Atomically *mem |= 1 << bit and return true if the bit was set in old value - of *mem. */ -/* The load-and-or instruction is used on z196 zarch and higher cpus - instead of a loop with compare-and-swap instruction. */ -#define atomic_bit_test_set(mem, bit) \ - ({ __typeof (*(mem)) __atg14_old; \ - __typeof (mem) __atg14_memp = (mem); \ - __typeof (*(mem)) __atg14_mask = ((__typeof (*(mem))) 1 << (bit)); \ - __atg14_old = atomic_or_val (__atg14_memp, __atg14_mask); \ - __atg14_old & __atg14_mask; }) - /* Atomically *mem &= mask and return the old value of *mem. */ /* The gcc builtin uses load-and-and instruction on z196 zarch and higher cpus instead of a loop with compare-and-swap instruction. */ diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index deb6cadaa35e841e23cee55d169a20538bdb1f8d..c5eb5c639fb59d7395c0a2d8f4fd72452845914b 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -159,10 +159,6 @@ # define atomic_max_relaxed(mem, value) asm_amo ("amomaxu", "", mem, value) -# define atomic_bit_test_set(mem, bit) \ - ({ typeof (*mem) __mask = (typeof (*mem))1 << (bit); \ - asm_amo ("amoor", ".aq", mem, __mask) & __mask; }) - #else /* __riscv_atomic */ # error "ISAs that do not subsume the A extension are not supported" #endif /* !__riscv_atomic */ diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h index aead3d5866d12b3b6bba27a1ef4a273400e1715b..3bf84d06bc875fca75b38b5ab01fca6683d390f7 100644 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/sh/atomic-machine.h @@ -301,97 +301,3 @@ #define atomic_increment_and_test(mem) atomic_add_zero((mem), 1) #define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1) - -#define atomic_bit_set(mem, bit) \ - (void) ({ unsigned int __mask = 1 << (bit); \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.b @%0,r2\n\ - or %1,r2\n\ - mov.b r2,@%0\n\ - 1: mov r1,r15"\ - : : "u" (mem), "u" (__mask) \ - : "r0", "r1", "r2", "memory"); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.w @%0,r2\n\ - or %1,r2\n\ - mov.w r2,@%0\n\ - 1: mov r1,r15"\ - : : "u" (mem), "u" (__mask) \ - : "r0", "r1", "r2", "memory"); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.l @%0,r2\n\ - or %1,r2\n\ - mov.l r2,@%0\n\ - 1: mov r1,r15"\ - : : "u" (mem), "u" (__mask) \ - : "r0", "r1", "r2", "memory"); \ - else \ - abort (); \ - }) - -#define atomic_bit_test_set(mem, bit) \ - ({ unsigned int __mask = 1 << (bit); \ - unsigned int __result = __mask; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("\ - mova 1f,r0\n\ - .align 2\n\ - mov r15,r1\n\ - mov #(0f-1f),r15\n\ - 0: mov.b @%2,r2\n\ - mov r2,r3\n\ - or %1,r2\n\ - mov.b r2,@%2\n\ - 1: mov r1,r15\n\ - and r3,%0"\ - : "=&r" (__result), "=&r" (__mask) \ - : "u" (mem), "0" (__result), "1" (__mask) \ - : "r0", "r1", "r2", "r3", "memory"); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("\ - mova 1f,r0\n\ - .align 2\n\ - mov r15,r1\n\ - mov #(0f-1f),r15\n\ - 0: mov.w @%2,r2\n\ - mov r2,r3\n\ - or %1,r2\n\ - mov.w %1,@%2\n\ - 1: mov r1,r15\n\ - and r3,%0"\ - : "=&r" (__result), "=&r" (__mask) \ - : "u" (mem), "0" (__result), "1" (__mask) \ - : "r0", "r1", "r2", "r3", "memory"); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("\ - mova 1f,r0\n\ - .align 2\n\ - mov r15,r1\n\ - mov #(0f-1f),r15\n\ - 0: mov.l @%2,r2\n\ - mov r2,r3\n\ - or r2,%1\n\ - mov.l %1,@%2\n\ - 1: mov r1,r15\n\ - and r3,%0"\ - : "=&r" (__result), "=&r" (__mask) \ - : "u" (mem), "0" (__result), "1" (__mask) \ - : "r0", "r1", "r2", "r3", "memory"); \ - else \ - abort (); \ - __result; }) diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index c27a437ec1b129fc18ca832708a69627959fc107..6adc219bf69f1507624618ed931dad11fea4e150 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -292,56 +292,6 @@ __result; }) -#define atomic_bit_set(mem, bit) \ - do { \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "orb %b2, %0" \ - : "=m" (*mem) \ - : "m" (*mem), IBR_CONSTRAINT (1L << (bit))); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "orw %w2, %0" \ - : "=m" (*mem) \ - : "m" (*mem), "ir" (1L << (bit))); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "orl %2, %0" \ - : "=m" (*mem) \ - : "m" (*mem), "ir" (1L << (bit))); \ - else if (__builtin_constant_p (bit) && (bit) < 32) \ - __asm __volatile (LOCK_PREFIX "orq %2, %0" \ - : "=m" (*mem) \ - : "m" (*mem), "i" (1L << (bit))); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (LOCK_PREFIX "orq %q2, %0" \ - : "=m" (*mem) \ - : "m" (*mem), "r" (1UL << (bit))); \ - else \ - __atomic_link_error (); \ - } while (0) - - -#define atomic_bit_test_set(mem, bit) \ - ({ unsigned char __result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "btsb %3, %1; setc %0" \ - : "=q" (__result), "=m" (*mem) \ - : "m" (*mem), IBR_CONSTRAINT (bit)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "btsw %3, %1; setc %0" \ - : "=q" (__result), "=m" (*mem) \ - : "m" (*mem), "ir" (bit)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "btsl %3, %1; setc %0" \ - : "=q" (__result), "=m" (*mem) \ - : "m" (*mem), "ir" (bit)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (LOCK_PREFIX "btsq %3, %1; setc %0" \ - : "=q" (__result), "=m" (*mem) \ - : "m" (*mem), "ir" (bit)); \ - else \ - __atomic_link_error (); \ - __result; }) - - #define __arch_and_body(lock, mem, mask) \ do { \ if (sizeof (*mem) == 1) \ From patchwork Wed Jul 6 15:15:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=hNyPo/0m; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNRJ1DS6z9ryY for ; Thu, 7 Jul 2022 01:16:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00872385841F for ; Wed, 6 Jul 2022 15:16:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00872385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120570; bh=ChkGb6bux0ElpBhIn8Y95eldwrygFxPd+cQy9Hmj53k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hNyPo/0mwOz7vEJF2Wd4/AxUl+OS8H1FfD9RZObqNeBA7e/xs482T8vJ22aTyLsim Jf1DIshErDxSgb06PmPrq8KNg2KocEYkgWYSCtQn9acQRFce88ngmxzIw+VORe90yo kxAvy5kNV0e7OKxP1CdL4gwNyuldsBq64SqYNRAo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.73]) by sourceware.org (Postfix) with ESMTPS id 28E0D3858C20 for ; Wed, 6 Jul 2022 15:15:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 28E0D3858C20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ELIZlnnEVG4BBv7nVE/Lo0hGm+pNWtrksxaju4GMyBt3UYeg4QmQ9M83QYKAyu5EFRsXQoxD0UICrI6plJSOvamL1GYsd6JRN9bAD1C52f3Whihof/IyqOLUJkeROLWPlctEMIAV7y0kZGuMt2Qzkc1g3ra1MIjc5AW+CTIRXefLrQ6SiMtwokzgQrDHJLyzT1CuNkucjbh+LtpD+1HKbmtlKxjuI7hsqeZ+Ds7K3sTRsRaBPbQT5WkgsByRaVarW59hriWDoLbhOW6RbQ2+rSoPL3/4saXQ1zlyyV9Zr3Zcga5a2X9PQmbqFn/HRdcT7BenvvTfbi0HZyaYgVE7nQ== ARC-Message-Signature: i=2; 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=ChkGb6bux0ElpBhIn8Y95eldwrygFxPd+cQy9Hmj53k=; b=TxH3rWOP6jmQP7TFGPMsfhEjdXGU9fmci1MOWW/BjD0DZRZQ65T6tJ3+8RYniylNA7uZKhTanYBCzhUz7VfWtOYV/di7F9akwmNaDfzXuyj+E1AY/iR08hj3w//4dppDlAou+zKrBEWL2IFyT8Xoa5nMZd5Y2Q+87ZvRbBrhwrHt75TneLyn7vBpyhYeeuZCHwv1YY6H6Zunh1aX3iDhTPQ5JkpXZcGqt4Wsry2OBA78BOFaFHrU5CzhcY19CqU2OjGGWAp3K0sehIpvcQ+bS+CkPmPcblugsqhkeLn+P2Pfcpn4VWueFD73i4mavcJhLzmveVrjSPJg0RCCuuwKHg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR01CA0001.eurprd01.prod.exchangelabs.com (2603:10a6:20b:540::6) by AM6PR08MB4168.eurprd08.prod.outlook.com (2603:10a6:20b:aa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.18; Wed, 6 Jul 2022 15:15:51 +0000 Received: from AM5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:540:cafe::8b) by AS9PR01CA0001.outlook.office365.com (2603:10a6:20b:540::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16 via Frontend Transport; Wed, 6 Jul 2022 15:15:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT027.mail.protection.outlook.com (10.152.16.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:15:50 +0000 Received: ("Tessian outbound 13cb25bfb745:v122"); Wed, 06 Jul 2022 15:15:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3cf2df02ed70862f X-CR-MTA-TID: 64aa7808 Received: from 49e770a2d745.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D83AB534-1063-461D-8346-107D06D3DE4F.1; Wed, 06 Jul 2022 15:15:43 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 49e770a2d745.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:15:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kbx0auClfuS9luHO5m40lIF+8XQe2QoC812kOvhVvJF+E+wIe7d5IlNlTFEMlTeB6CiNtKSr3DO8wrSo68YSh5E0h/WevRmUgTq0BfY7cMgrfqKZKJ3dgk7a+gM5uFliRJXCTsWmQKemW0LdAE30GUAZ0tm9bMawvNpo2++tzjTY7MDmHnVDddvjFIvYU+WV+Pb1vNjmW8LOHmRKB+ZhMIKpbsY2MyDWWppRP+lvMJReChclJ+8WkdpDE9UvfN3bkBUOt+ncEUutTGxc3ucJmmvP5u18TXG4Kg1jWOQPRjDf9TPL77Bhh/d1bF3hdyDH3yaBLI1XZIVQ8Dth618b9w== 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=ChkGb6bux0ElpBhIn8Y95eldwrygFxPd+cQy9Hmj53k=; b=ODB47C954KJAFhxvtH+C85upI02hvQ9IvEmldZlpj9XXRZkkbZxT3QjAjU2frT8fkCdgOM9ilz/sNkbhDcovTv0bunnEQeF/2UDVkeILnMk+AvAcfstLVTP+JNOXPUlrV2Nt1lYiGhEhhZrPFIv9QHPaaPOGYM89Z0Q+V52pnmmlqOm9cJuwNj0LFL9RYn0E4kF80753rH/BJIWBf6oW0sPWbEPE8XsJ2ROXNFM1ipv8Vs3QNJ5ArZwM4yGKDRUGdlK4UuamjrdSbp4PEXDkoA1hWpLu0m42b3fV0EgBA9yW2XMJobLmBbjZwwoLydEvdyMf3oFBw53VvCjTJnL38A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM4PR0802MB2178.eurprd08.prod.outlook.com (2603:10a6:200:5a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:15:41 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:15:41 +0000 To: 'GNU C Library' Subject: [PATCH 4/7] Remove atomic_and/or Thread-Topic: [PATCH 4/7] Remove atomic_and/or Thread-Index: AQHYkUse/lXiHmNutk6wTNqxE3QEwA== Date: Wed, 6 Jul 2022 15:15:41 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 6a2641bc-1cbc-4f20-a16a-08da5f626994 x-ms-traffictypediagnostic: AM4PR0802MB2178:EE_|AM5EUR03FT027:EE_|AM6PR08MB4168:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IGE6OKW0l6bWIn9/LgNuLiqgbhSAsBaatArf139Iafve6lwVtAYJoaD8Efn4DDCAPyJS75stPk6to1Ez6i8XPSTxSFdvCCw+zRDot0SbXRRRE80fNY24gdZrN2kP7WZ3C2tt1QY17KYsB0EgOtwTRz9nJtbcWTtIz0NxzoHoLWsQNaGax4xAepyl5HIL48SoxJCFrQLGwVwYRakS7X9y4I6sXXwzks6zL/HVHgVrh5awcbh4e+TRuJ87f0bIauavojrfOJg1vX/dg1WsDHHrOVw6wVeGrGWMLwiE+dgH2jTandTFKwY3gtx7duTdIjmgYo1kjXcX2XCfq56EPL7w3DIhVOYrkP406xsGq8FavbaUW3k173WKLrWmzyfGv5V65M3i6gCWX7Mpvqx+UausCRmd8OjUsts9xquA1x2L0wclXw5H+p1lrAEeYlwbLPTytBUEeIuoNXpVXr4qVvj0hdaYINbza6ZtQn8a8PfGgY2kMvVFzhnGwI28SSL71GrDaZ9oBHT65NQhLvnsrkUWJAFqmMyM86dHdaVx6UJRTV40KJKeYkiatfiQvlwdLw0P9D2w+oc6qR3Xf5iry+U8VzpcOvgETeu3XFdtnCSXbhAY3lnTdd2akCKk8Xs5swyB0bUE/XqXw6VBkmcHTBBsvYL/HfwYZYjlWpz/y0Ie6uubeZ/tHxDegIthsRkgbncMqxtJPqYsdzT/Nh1e8xiVOMVC2zAG6VrIEWnIwNuTNHB8PTtFPH6lfeUZ64qkCC2TZO0R++E6gS2kOA1B5xE7U4xt4xmwffnC1mKaCVJq6Uwyr3gaqbwbEJ0plzKbOXPW X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(366004)(39860400002)(83380400001)(38070700005)(52536014)(9686003)(122000001)(186003)(6916009)(316002)(8936002)(5660300002)(2906002)(26005)(33656002)(41300700001)(478600001)(91956017)(66946007)(66556008)(55016003)(76116006)(8676002)(6506007)(86362001)(7696005)(38100700002)(66476007)(71200400001)(64756008)(66446008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2178 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: aeef6adb-ebf7-4f07-f695-08da5f6263e5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yYWKWbhP43uFaIxHfhLEs6tfKN6TCBkgkrAXzhqK4gT3YjNeJFOfeaUJO0zxWOuh/73qynmHcDnthkjRXJKZUt44i3q+q9xwCBpXSOUTaBnKlmj4YCmMsRZeKyi95BiG6rIMGh7z2AT4TlZTQehmjvBdlYlgP19FXk3G7pEAx9e2m+jQxyDk/IY2nBQ1HhMrhx4t+tLxCzffcesge1js4pzyigEH89fd2JcxGCiGwB5K7a95GtylbMvUJMXEoLsBYZ3Jij4sOK4rhgmwv1hZZp08P5Z8LvpmSzbjdgrUG7hO9L+4sbYenzucFRnQ959qMuV0UBd46rylWWu74fSZ2aRS8gBZuxSGHB3Jqc3gDEMFeEzJS66kBkMycJoXyaH2LUM7arV6H3ZUEUWaH+DW/CR3ctj2NRV6k8MJDqbu0hc6VyQ+qhi3J/hRGl5zpvSwozQbaWPYJV8ZvBgZSztEpZLq07EWOtboNFHGDUxHRxewy7LuoqxXGTOiSahbPPQuWhTJ9HMU5m3f5ZZNGI4KjQy95b+G6WAMjJoW/GHYhFZkkDNjpJ/NR1+VWg0byiURca5GP1gVRQcbiKYHnXdkIh14KJEzFS+lFtTmI+xwoU6Q0ICMD67RMa0sobmFutSWjzPsLbKWsrlQy9TrS5pu3jp0R/LjcqR0/eVMWsH9ZtoGpfDqfMKEG2VUjqdrfXAwOD5ME2Q/bNK+nQcnM45XGmC62qRZrLZW0rYkP+MRUs2An9EZmn0V0MLUIvh90GdPnaJsnenW3PrW31eONB+okGcK487GYZyNkd9QaspHIlJdiTGFE51rLjcOgNP0LMSy X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(376002)(396003)(136003)(39860400002)(346002)(36840700001)(46966006)(40470700004)(40480700001)(55016003)(36860700001)(40460700003)(336012)(82310400005)(47076005)(186003)(83380400001)(33656002)(7696005)(8676002)(70206006)(70586007)(86362001)(9686003)(52536014)(5660300002)(8936002)(6506007)(81166007)(356005)(82740400003)(478600001)(6916009)(41300700001)(316002)(26005)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:15:50.8399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a2641bc-1cbc-4f20-a16a-08da5f626994 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4168 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Replace the 4 uses of atomic_and and atomic_or with atomic_fetch_and_acquire and atomic_fetch_or_acquire. diff --git a/include/atomic.h b/include/atomic.h index ed1fc38e7569fcbdd0473ab6f69956a44d62354f..fd1a1eb0f87d288251d176d69246cff2d3422af7 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -255,23 +255,6 @@ #endif -/* Atomically *mem &= mask. */ -#ifndef atomic_and -# define atomic_and(mem, mask) \ - do { \ - __typeof (*(mem)) __atg15_old; \ - __typeof (mem) __atg15_memp = (mem); \ - __typeof (*(mem)) __atg15_mask = (mask); \ - \ - do \ - __atg15_old = (*__atg15_memp); \ - while (__builtin_expect \ - (atomic_compare_and_exchange_bool_acq (__atg15_memp, \ - __atg15_old & __atg15_mask, \ - __atg15_old), 0)); \ - } while (0) -#endif - /* Atomically *mem &= mask and return the old value of *mem. */ #ifndef atomic_and_val # define atomic_and_val(mem, mask) \ @@ -289,23 +272,6 @@ __atg16_old; }) #endif -/* Atomically *mem |= mask and return the old value of *mem. */ -#ifndef atomic_or -# define atomic_or(mem, mask) \ - do { \ - __typeof (*(mem)) __atg17_old; \ - __typeof (mem) __atg17_memp = (mem); \ - __typeof (*(mem)) __atg17_mask = (mask); \ - \ - do \ - __atg17_old = (*__atg17_memp); \ - while (__builtin_expect \ - (atomic_compare_and_exchange_bool_acq (__atg17_memp, \ - __atg17_old | __atg17_mask, \ - __atg17_old), 0)); \ - } while (0) -#endif - /* Atomically *mem |= mask and return the old value of *mem. */ #ifndef atomic_or_val # define atomic_or_val(mem, mask) \ diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 4b7f3edc384748f300ca935ad878eb0e3547e163..1e6b385787aab5fa2f452de0cd2eae2b5f0fba83 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -539,7 +539,7 @@ start_thread (void *arg) # endif this->__list.__next = NULL; - atomic_or (&this->__lock, FUTEX_OWNER_DIED); + atomic_fetch_or_acquire (&this->__lock, FUTEX_OWNER_DIED); futex_wake ((unsigned int *) &this->__lock, 1, /* XYZ */ FUTEX_SHARED); } diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 6e767a87247063c0ac84242ef13e72af79021104..439b1e6391c50d5922dec6c48e7f2a2a632a89d9 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -462,7 +462,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { - atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); + atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); /* We got the mutex. */ mutex->__data.__count = 1; diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 0fcaabfb482546fd6f1f9cc4b13edc82f6e6796c..af70a60528cb101c8e52d4165950ee0d11f6f895 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -392,7 +392,7 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { - atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); + atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); /* We got the mutex. */ mutex->__data.__count = 1; diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 8a7de8e598803f606899fe1c9b8775bc24dd14ec..50524942a76c753ce4add20c35dfe7f659a1908b 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -308,7 +308,7 @@ ___pthread_mutex_trylock (pthread_mutex_t *mutex) if (__glibc_unlikely (oldval & FUTEX_OWNER_DIED)) { - atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); + atomic_fetch_and_acquire (&mutex->__data.__lock, ~FUTEX_OWNER_DIED); /* We got the mutex. */ mutex->__data.__count = 1; diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h index db31e377970c4ab6285ef65fb21419db7c6ca373..d2fc3cf240888ca3569c6d3b1287cc87209cab89 100644 --- a/sysdeps/s390/atomic-machine.h +++ b/sysdeps/s390/atomic-machine.h @@ -80,27 +80,3 @@ # define atomic_exchange_and_add_rel(mem, operand) \ ({ __atomic_check_size((mem)); \ __atomic_fetch_add ((mem), (operand), __ATOMIC_RELEASE); }) - -/* Atomically *mem |= mask and return the old value of *mem. */ -/* The gcc builtin uses load-and-or instruction on z196 zarch and higher cpus - instead of a loop with compare-and-swap instruction. */ -#define atomic_or_val(mem, operand) \ - ({ __atomic_check_size((mem)); \ - __atomic_fetch_or ((mem), (operand), __ATOMIC_ACQUIRE); }) -/* Atomically *mem |= mask. */ -#define atomic_or(mem, mask) \ - do { \ - atomic_or_val (mem, mask); \ - } while (0) - -/* Atomically *mem &= mask and return the old value of *mem. */ -/* The gcc builtin uses load-and-and instruction on z196 zarch and higher cpus - instead of a loop with compare-and-swap instruction. */ -#define atomic_and_val(mem, operand) \ - ({ __atomic_check_size((mem)); \ - __atomic_fetch_and ((mem), (operand), __ATOMIC_ACQUIRE); }) -/* Atomically *mem &= mask. */ -#define atomic_and(mem, mask) \ - do { \ - atomic_and_val (mem, mask); \ - } while (0) diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 6adc219bf69f1507624618ed931dad11fea4e150..2abab58628e88bf2f5fc980d2de6b0dd556f6cd4 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -292,54 +292,6 @@ __result; }) -#define __arch_and_body(lock, mem, mask) \ - do { \ - if (sizeof (*mem) == 1) \ - __asm __volatile (lock "andb %b1, %0" \ - : "=m" (*mem) \ - : IBR_CONSTRAINT (mask), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "andw %w1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "andl %1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "andq %q1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else \ - __atomic_link_error (); \ - } while (0) - -#define atomic_and(mem, mask) __arch_and_body (LOCK_PREFIX, mem, mask) - -#define __arch_or_body(lock, mem, mask) \ - do { \ - if (sizeof (*mem) == 1) \ - __asm __volatile (lock "orb %b1, %0" \ - : "=m" (*mem) \ - : IBR_CONSTRAINT (mask), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "orw %w1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "orl %1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "orq %q1, %0" \ - : "=m" (*mem) \ - : "ir" (mask), "m" (*mem)); \ - else \ - __atomic_link_error (); \ - } while (0) - -#define atomic_or(mem, mask) __arch_or_body (LOCK_PREFIX, mem, mask) - /* We don't use mfence because it is supposedly slower due to having to provide stronger guarantees (e.g., regarding self-modifying code). */ #define atomic_full_barrier() \ From patchwork Wed Jul 6 15:17:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mmt0B4Lg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNSx4jKLz9ryY for ; Thu, 7 Jul 2022 01:17:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DDF2385840A for ; Wed, 6 Jul 2022 15:17:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DDF2385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120655; bh=3DD3ONhox2Bk6L2w8QUTwA3jhcYnImbnO4/jF9vNUbs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mmt0B4LgPrcXGYRezQUP2WyVdniPlDKOby6UHO5ppQAyIn0eTKv3GI2hNWPdLLtFv h6kkntQUb8kcz44gB2/V7UfAHjFvWb4Jp6qaMjHKcd5lflLnaD0mYd4XnLDmf0Tz3O hDL1eeDbun5y/MYCm/W9zpUS4V3Bj6vcBwsr059M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60087.outbound.protection.outlook.com [40.107.6.87]) by sourceware.org (Postfix) with ESMTPS id A08AB3858C20 for ; Wed, 6 Jul 2022 15:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A08AB3858C20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Ok1jTJf2on3z4QwmBjvaI35g+0R8F+pnD4EwpT+irHTyLjPlYIeIQ0YiiPgs+zWXNaP3VqF9zfgGpuW2TftwD2atr75tCqoi2YIg/kBcFHh7RE31yx5TqfnE4voghZqJ43B8SKehXo7SWuBToPhVrsYMn9YMYLLKijHp4o07W6eQbOIjZJDxQ6DXJieVMynOnPfxDe8WBSEHK8d9PTFWvHdi0D0fh2oVqgcSejlH81prYkpH78BGQYcX7XZytram6ogp27peTINKNoOf/1CH6bWGr3wR1q6qvTor8YiR9sHjpMd5EjH422z7hGOY1xbRhJ4o3oVUcmTSqfr3gjXnew== ARC-Message-Signature: i=2; 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=3DD3ONhox2Bk6L2w8QUTwA3jhcYnImbnO4/jF9vNUbs=; b=XNbBy7wBNbqUiLQaDs6En+SCLoncCVP2Yf/dJOPTy222MHKsEITGU1chaekNuOV36wKaAbbISPhL9K19xx2gq7/SK6EQDlRb7OW7vMevCcdA7jNMLKrlxZq6fsozSfxhxceaQ5I+vRgj9hjMEsnR3boEhd4FBhzePbJVz4IH0bJpq8N9US05Qnq6Xcj6mW810PCeHRo21QneY75obJuD/bnMOQn4AU4GXdDrKbm3/31sVuKV5FfRzyioYKKQlcBULCWSNjc2HM6FuHrRf8SCPJZpu2yiSPK16KOMtfN/JAUtGjneSziJPaChn9u0L3BcmjI4C7/fxIQ4x6E/LRoaTw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB8PR06CA0039.eurprd06.prod.outlook.com (2603:10a6:10:120::13) by DBAPR08MB5846.eurprd08.prod.outlook.com (2603:10a6:10:1b0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Wed, 6 Jul 2022 15:17:15 +0000 Received: from DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::b7) by DB8PR06CA0039.outlook.office365.com (2603:10a6:10:120::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15 via Frontend Transport; Wed, 6 Jul 2022 15:17:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT015.mail.protection.outlook.com (100.127.142.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:17:14 +0000 Received: ("Tessian outbound 8e3d5168572a:v122"); Wed, 06 Jul 2022 15:17:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b148c141c6301908 X-CR-MTA-TID: 64aa7808 Received: from a01307202731.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 526A0141-C4FE-4A63-868A-9E5D370BFF56.1; Wed, 06 Jul 2022 15:17:08 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a01307202731.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:17:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H8P4ggWXgCkBszW15zgtFTPbj1ikKNZlJORgqTMojcPlmMdGuW/g12Lmquy7FRF7SEeo6M5Lo90+oMGFOQte7PcMCBq1Q2zrsOyNwzn76gVd22u9FXPDcuAun0BCydOtQgli/DoXhFG0iL0jxwIZbYF54zFTbCiw72+JYIDiOZ8EotqWe9PRmF1ZxKlQxy71YSjZIXvQ9Xe2nxkb6h/chRij75Rs4nJR/sbKWcGtWYa/Ubo4SVEOMMg0raxw1QILfK/F0HWAd3YXgbOuzZyCSnx3Hrrnlwel3H03ycvXdPVThexv+TuS9dOf3VFVRJvpv+lXsQzLtideHc5s3naRPw== 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=3DD3ONhox2Bk6L2w8QUTwA3jhcYnImbnO4/jF9vNUbs=; b=FKtlUPFc9kzKdJv9fpkUQM9h/k2fCg3TUDiRru+pZXvOQq9JFXuxSFMEhb0qWWZEhJ5C/PxRJbVPaCclnwjk78H2ZVnU/azzgkZRGWd9EzHO728pFWlaUP2R0PALddTjSc5fLCCcnvhsfGaN6axbHa4yQcQLRV+GGoRCr77PIKpsH9B6wgZlygJU9H5xe5tdB/TwRxBRfX08k05eKCOJhiyzVq+K0dHyfQROCfpDNU3angQ9WNXgwcaiyibxzcFvm+RwqJfecgImNI8ZwIxQFqs9zBRE5imim7I/D3taI460H58hbjKZjKDm8W5eay0pivGZaeVXAffQ14hx+H5Mzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM0PR08MB2996.eurprd08.prod.outlook.com (2603:10a6:208:5b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:17:06 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:17:06 +0000 To: 'GNU C Library' Subject: [PATCH 5/7] Remove atomic_add/add_negative/add_zero Thread-Topic: [PATCH 5/7] Remove atomic_add/add_negative/add_zero Thread-Index: AQHYkUtZtvQ7z6inokujVq7gluChBg== Date: Wed, 6 Jul 2022 15:17:06 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 9be9c803-7b4b-47d0-87ce-08da5f629bb5 x-ms-traffictypediagnostic: AM0PR08MB2996:EE_|DBAEUR03FT015:EE_|DBAPR08MB5846:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: qW0hhe80sHKjiY69EBpXYqW1vwAtB4FT+2cVeF0WLH7JHIGUV/HGiqJ3ac2l3byAayyaqEHlX80KdkOLAklaahJN97F63X0qrIhzYMd+MiIghdgiRLhUjKIWKJ1F7YmAJRiSvaoEDT5hx4OQ0oQBMn55t5U+B1+HlHOPFdczKWN7vCny2eLvyRBLfuxPG83qBXSOdBnY2ks8id0cAc2ybM54QPaaMIehN9FaFh0FUTicFC9x4Z/Fy2RrSv2EfcHmGh++fc78pQNJlzCuctgSftzZLGpMYV1RLo+igaEtAL/Rzt3iD5IXV3kVuk+phAicXU4XAKkXfop3SkP2Dz03MckynVTH7RRahLAF6PNUKBR8B8cwKsL/6fKPqRsmTAnbdjDA6WCrTK61Z0cZbXZxD00dohVW/zZPAZqMt+lo++67g1I6sL2zTEtCcuQRIgUrJcsrIGsPMps6y3MHXoS2VuF4m0k3Dtsx6dGWiqvfszLF9nZdc49ohWb/jyLExiqTJv6nlE7sOcufa69+krZNeaaWysD8U7hBhinDDWuqGFb/RvXxd+3267GzAM1hvBqri6Xvbkao4dboTnCMW1OMCutmQYPvMwKn0dFCWR73R+LphRsK5Psw87JsI4O1YFDO7G6WJU0yt1OwKMiMB0G+ovsheitX8t+1zALZ7O41PJRU4LX1Pm3yqlpuoLqt62K2ApwjJEpCn9J90qhRfJlUwXm5kEdtaIs+Y1D/72mWkrNmdaXNGkH0OVH6p6O2w+OLanQWtdHgCrcc2rGnQ9NiQiPgC+jzTt2mPETo/kH61AFyLvlZohkrQx6UR6jmXCpL X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(396003)(39860400002)(376002)(346002)(83380400001)(38070700005)(122000001)(38100700002)(316002)(71200400001)(52536014)(8936002)(91956017)(5660300002)(76116006)(8676002)(66476007)(66446008)(64756008)(66946007)(66556008)(9686003)(186003)(26005)(2906002)(478600001)(6506007)(41300700001)(7696005)(6916009)(33656002)(55016003)(86362001); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2996 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 47caacdd-e4e3-4185-7085-08da5f6296b7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xPzZTRFwJjOG5gbRxzlJf6EGCJjZN8EWUKkD4BCU/VdtSkbgEl+G3fcVvOJO3PHwL8tlPlVQBaFqDh52zefmRFH1fJApp5SRvSlRPcLvouKjF/7mbe9HVVWgEMQoiMIe8JsD6KmmFbRuIpIUQ7r4/at7uiPoVNly0ArJrCtjsuxbCMoOI0z5R2A3Vs12sSoY2lwntZ9QQ6mXpObpRltFayuLGryJxBoiBWyAvPKbTtMaKMOy/iYpaP+6xJHQSfBb0zRdE4kc3IjRvepDDvByffIYMytNlse0TuDISjtZAFuVZ4P9x0PfxSreCfXreGb08RkccbRxBnziWHlc2pRvl4+paLus9nYgdqA8GyfAerz1iGTnc3xjR/eaZp/YxcyGVYzbOMzJlcrgXaWaa5hm9pnsu6Mk3Bppns5cqRUp/RB+riOoB19JSY7QTphRaxG9FIS6ippTcQtctYh/UdLPhnJjolo7DfrUSAvljpVKYtOxb/hjgV7VdRc6JWZaAihzGDa62TcLpGub+bcyzzRuKKTUoom2psrafKGjtgXkPfzectcKcNZsMf5KqojWmeaIIZEax59Vd/LNOqsOqGXbEtU5qoHlWyCK77oqLgS5L9ZmLcEZcE/CzUECa5KKXr1lYzzlV87B+NzwtusPWrbGNV0PPpw0PJCDEsn19xbzQTGGi/W41j/hQcWEbagbDssUoQx7d0Tpkkw7l3FUZ4JlDdjn8SlwTBPgNF5ubPGexs10svK4v7H2J3qCFsJeuc0GW843BDV6fFZMmedZGxB/9VW2ThOUmjZsXrrXqeT610B5WAzPBHiwgMwx6Y6WAavI X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(376002)(346002)(396003)(136003)(39860400002)(36840700001)(46966006)(40470700004)(47076005)(336012)(83380400001)(6916009)(40460700003)(186003)(36860700001)(82740400003)(41300700001)(33656002)(316002)(82310400005)(9686003)(70206006)(70586007)(5660300002)(6506007)(81166007)(7696005)(52536014)(8936002)(356005)(478600001)(86362001)(40480700001)(2906002)(26005)(8676002)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:17:14.8583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9be9c803-7b4b-47d0-87ce-08da5f629bb5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5846 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Remove the 3 uses of atomic_add, atomic_add_zero and atomic_add_negative with atomic_fetch_add_relaxed. diff --git a/include/atomic.h b/include/atomic.h index 492485597a12950d946691cb98b1b3ecbed7d592..50778792e444238dddceb95386afd3d70450b2a1 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -224,20 +224,6 @@ #endif -#ifndef atomic_add_negative -# define atomic_add_negative(mem, value) \ - ({ __typeof (value) __atg12_value = (value); \ - atomic_exchange_and_add (mem, __atg12_value) < -__atg12_value; }) -#endif - - -#ifndef atomic_add_zero -# define atomic_add_zero(mem, value) \ - ({ __typeof (value) __atg13_value = (value); \ - atomic_exchange_and_add (mem, __atg13_value) == -__atg13_value; }) -#endif - - /* Atomically *mem &= mask and return the old value of *mem. */ #ifndef atomic_and_val # define atomic_and_val(mem, mask) \ diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 841ef2e2c6be2da8d1547cfb8bfcc03015154e58..67073c23c34126b87a6049b8d9ecd6cf2d9d23bc 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -120,14 +120,6 @@ do_test (void) ret = 1; } - mem = -21; - atomic_add (&mem, 22); - if (mem != 1) - { - puts ("atomic_add test failed"); - ret = 1; - } - mem = 17; atomic_decrement (&mem); if (mem != 16) @@ -190,102 +182,6 @@ do_test (void) ret = 1; } - mem = -12; - if (! atomic_add_negative (&mem, 10) - || mem != -2) - { - puts ("atomic_add_negative test 1 failed"); - ret = 1; - } - - mem = 0; - if (atomic_add_negative (&mem, 100) - || mem != 100) - { - puts ("atomic_add_negative test 2 failed"); - ret = 1; - } - - mem = 15; - if (atomic_add_negative (&mem, -10) - || mem != 5) - { - puts ("atomic_add_negative test 3 failed"); - ret = 1; - } - - mem = -12; - if (atomic_add_negative (&mem, 14) - || mem != 2) - { - puts ("atomic_add_negative test 4 failed"); - ret = 1; - } - - mem = 0; - if (! atomic_add_negative (&mem, -1) - || mem != -1) - { - puts ("atomic_add_negative test 5 failed"); - ret = 1; - } - - mem = -31; - if (atomic_add_negative (&mem, 31) - || mem != 0) - { - puts ("atomic_add_negative test 6 failed"); - ret = 1; - } - - mem = -34; - if (atomic_add_zero (&mem, 31) - || mem != -3) - { - puts ("atomic_add_zero test 1 failed"); - ret = 1; - } - - mem = -36; - if (! atomic_add_zero (&mem, 36) - || mem != 0) - { - puts ("atomic_add_zero test 2 failed"); - ret = 1; - } - - mem = 113; - if (atomic_add_zero (&mem, -13) - || mem != 100) - { - puts ("atomic_add_zero test 3 failed"); - ret = 1; - } - - mem = -18; - if (atomic_add_zero (&mem, 20) - || mem != 2) - { - puts ("atomic_add_zero test 4 failed"); - ret = 1; - } - - mem = 10; - if (atomic_add_zero (&mem, -20) - || mem != -10) - { - puts ("atomic_add_zero test 5 failed"); - ret = 1; - } - - mem = 10; - if (! atomic_add_zero (&mem, -10) - || mem != 0) - { - puts ("atomic_add_zero test 6 failed"); - ret = 1; - } - /* Tests for C11-like atomics. */ mem = 11; if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11) diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index fdb4d71cb5890272cec88d3af73aef463ff11c8b..0b77a2d897027edc36e956301f018c2ab0121444 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -278,7 +278,7 @@ make_request (int fd, pid_t pid) { free (result); - atomic_add (&noai6ai_cached.usecnt, 2); + atomic_fetch_add_relaxed (&noai6ai_cached.usecnt, 2); noai6ai_cached.seen_ipv4 = seen_ipv4; noai6ai_cached.seen_ipv6 = seen_ipv6; result = &noai6ai_cached; @@ -349,7 +349,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, *in6ai = data->in6ai; if (olddata != NULL && olddata->usecnt > 0 - && atomic_add_zero (&olddata->usecnt, -1)) + && atomic_fetch_add_relaxed (&olddata->usecnt, -1) == 1) free (olddata); return; @@ -377,7 +377,7 @@ __free_in6ai (struct in6addrinfo *ai) (struct cached_data *) ((char *) ai - offsetof (struct cached_data, in6ai)); - if (atomic_add_zero (&data->usecnt, -1)) + if (atomic_fetch_add_relaxed (&data->usecnt, -1) == 1) { __libc_lock_lock (lock); diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h index 2f45171240ce8d1970b101134a5c838b8a621cb9..6d4f8bdf1a9a96153c86c7a7fc9a796bc4feac7b 100644 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/sh/atomic-machine.h @@ -201,55 +201,6 @@ } \ }) -#define atomic_add_negative(mem, value) \ - ({ unsigned char __result; \ - __typeof (*(mem)) __tmp, __value = (value); \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.b @%2,r2\n\ - add %1,r2\n\ - mov.b r2,@%2\n\ - 1: mov r1,r15\n\ - shal r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.w @%2,r2\n\ - add %1,r2\n\ - mov.w r2,@%2\n\ - 1: mov r1,r15\n\ - shal r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.l @%2,r2\n\ - add %1,r2\n\ - mov.l r2,@%2\n\ - 1: mov r1,r15\n\ - shal r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else \ - abort (); \ - __result; }) - #define atomic_add_zero(mem, value) \ ({ unsigned char __result; \ __typeof (*(mem)) __tmp, __value = (value); \ diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 97d9d4a194a9d7deddbaa1781a1f9484a3e9232d..2f180abe9e682f9e64b471d091e455e192b156ba 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -122,82 +122,6 @@ #define atomic_exchange_and_add(mem, value) \ __sync_fetch_and_add (mem, value) -#define __arch_add_body(lock, pfx, apfx, mem, value) \ - do { \ - if (__builtin_constant_p (value) && (value) == -1) \ - pfx##_decrement (mem); \ - else if (sizeof (*mem) == 1) \ - __asm __volatile (lock "addb %b1, %0" \ - : "=m" (*mem) \ - : IBR_CONSTRAINT (value), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "addw %w1, %0" \ - : "=m" (*mem) \ - : "ir" (value), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "addl %1, %0" \ - : "=m" (*mem) \ - : "ir" (value), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "addq %q1, %0" \ - : "=m" (*mem) \ - : "ir" ((int64_t) cast_to_integer (value)), \ - "m" (*mem)); \ - else \ - do_add_val_64_acq (apfx, (mem), (value)); \ - } while (0) - -# define atomic_add(mem, value) \ - __arch_add_body (LOCK_PREFIX, atomic, __arch, mem, value) - -#define atomic_add_negative(mem, value) \ - ({ unsigned char __result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "addb %b2, %0; sets %1" \ - : "=m" (*mem), "=qm" (__result) \ - : IBR_CONSTRAINT (value), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "addw %w2, %0; sets %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" (value), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "addl %2, %0; sets %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" (value), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (LOCK_PREFIX "addq %q2, %0; sets %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" ((int64_t) cast_to_integer (value)), \ - "m" (*mem)); \ - else \ - __atomic_link_error (); \ - __result; }) - - -#define atomic_add_zero(mem, value) \ - ({ unsigned char __result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "addb %b2, %0; setz %1" \ - : "=m" (*mem), "=qm" (__result) \ - : IBR_CONSTRAINT (value), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "addw %w2, %0; setz %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" (value), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "addl %2, %0; setz %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" (value), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (LOCK_PREFIX "addq %q2, %0; setz %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "ir" ((int64_t) cast_to_integer (value)), \ - "m" (*mem)); \ - else \ - __atomic_link_error (); \ - __result; }) - - #define __arch_decrement_body(lock, pfx, mem) \ do { \ if (sizeof (*mem) == 1) \ From patchwork Wed Jul 6 15:18:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ReR1BgLc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNVp4P6Bz9ryY for ; Thu, 7 Jul 2022 01:19:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F00E1385801C for ; Wed, 6 Jul 2022 15:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F00E1385801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120751; bh=FebK43HXr2GAqdZUADxKNH+2NlDaxs7D+vpel47FayY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ReR1BgLcVlvtaQP7PEtL/8rFYEsvzHkRhNTB/oH41ugBdhRiYIMkm1G6ViwOLg1i5 Y0rTHisdscb5O4NuCksFpnwM3tR++Jdvc7FugzYPdQhyzBrCUKM0VzieRjoCh4EBFF Weca1x2VtfvZD/9k+D4agOeQSwY1OV+JQkYkJGH4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2089.outbound.protection.outlook.com [40.107.20.89]) by sourceware.org (Postfix) with ESMTPS id DB4703858C39 for ; Wed, 6 Jul 2022 15:18:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB4703858C39 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=dB93ul9HuYu84agqOcl3Zn3ontU0qeUTfOhqyBK51lR1qt0pQ9VaB1clH7yyX2pR9UlQQDUP2L33DkkjsSjwXXkhQOEsbn7TfxGifSUBNBHz0ffVvUW/WvAqruk2G9XSMZnJEMUn7xguUrnYKVr2zAHR5B0GYK5wGNjCBqUmYU7TtmgQKB/NDCP3BzQMZdg9jrdQxS7dPWdOPdDmoL2wqa9AJlJ1kctNa9OafawMCZKqxeb4lC50i4l+MsjRQTLIEjW80zjXrYP2gj0A+jOuUgbyqSU6CTxCNkwApdr5M4cuBVeMsa6H54Gp/gbJTzHVdTiv1OdiZ04kBWAZj9LKSQ== ARC-Message-Signature: i=2; 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=FebK43HXr2GAqdZUADxKNH+2NlDaxs7D+vpel47FayY=; b=iqfOg/OSOTNoKdyVv0x0aHiAB2HZQaBgR/EBGxK7eQo//4lv6ed66hcM1i+S5fAftCs7btuyeOO4GXNXuVbN+dipFbFPJlV57P40lEBaj1Ojc2fTdcIgyBVvnzVPQALOBnRICBLMycuQ/QY6TL6Su3crJ2wd3rekocTC65DO8aie33htQ/nFZ5ugZRO7zXiNwXHKhkzeuUGA38uMttSkhZ+hdiaT513hPOnY67HV9+os/7WUZx2jMkIvUGT+oSwrEiSqxvmypj/za2R+18L6+tH+ugCG9+wtZKZiOCjYwQRmuOpv3FX6Y0XgH426RYSzHDvRsL9nowNG2mgY+oHAJA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AM6P191CA0065.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::42) by GV2PR08MB7954.eurprd08.prod.outlook.com (2603:10a6:150:a8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.17; Wed, 6 Jul 2022 15:18:51 +0000 Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::8e) by AM6P191CA0065.outlook.office365.com (2603:10a6:209:7f::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16 via Frontend Transport; Wed, 6 Jul 2022 15:18:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:18:50 +0000 Received: ("Tessian outbound 6f9e7ef31fa8:v122"); Wed, 06 Jul 2022 15:18:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9861244e0c259b0e X-CR-MTA-TID: 64aa7808 Received: from 09816b478095.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9EA0AC3C-4E7F-4C14-BA26-1542B6150581.1; Wed, 06 Jul 2022 15:18:43 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 09816b478095.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:18:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iDFnajK9zuTdgBnB+ND1YfYwXkiNrOoqYSMN2vTeb+B2+1eVbQK0gKWzXtdpN1OT39fmxvGDY6FIWM5PgEDJ47Yla4Zbyc9/nykb5Iq/85tsAtrvuz0Gk/oxt0Ah8Kn3XRxHmqtouT8TP2bdJQHuxAT1i4/kf44+iXxx1EztCQRKy4YfVG6xFx82nXlw6Zhz8s6SWVnVdqb+fT8GwbtTGG2YJRt9+tLdG5Hk/TJ20HtLmg+0w4ZDbVahLhDOdCU55LjPBEWSGW52Ugh8cM2mrXpucr5ppwyF953lZNsxmJaE6fiZmHKX7gTpvaeNyKNjKlt2mO4VGrSffubJL2xFvQ== 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=FebK43HXr2GAqdZUADxKNH+2NlDaxs7D+vpel47FayY=; b=BP25xi2d5aIxU1M9upHrF61/wBSEdeSLUmxdO+VXyihfM23iB/BdmSxdk8ZIRn0Ys2DXiCOr0PWHirDizXmhuhRQaSZB/ocd6moncINaatFB9j8YDt7CNjms9YM1u38RDRzbzIUbEuzag0k7+VQOKjm2k7+YHw3Hhb2qkDWt/8bNkEP+QyvmLXiYELZ8iLVdlf9FxYmcIYdtbgUzp9y/ZsKbIvHiFMm6L7w+fPuSlLae5tkDI1MKaM2/TWYou8JMwb7TSi2EdCZ8L8f6MuFT7fMU3T3Mv5XCGxDIGzQgXZhRuYl9QYQ/9/iCmMmfP5CaFi8JRhouidvHr3MdHi6c1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM0PR08MB2996.eurprd08.prod.outlook.com (2603:10a6:208:5b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:18:41 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:18:41 +0000 To: 'GNU C Library' Subject: [PATCH 6/7] Remove atomic_increment/increment_and_test/increment_val Thread-Topic: [PATCH 6/7] Remove atomic_increment/increment_and_test/increment_val Thread-Index: AQHYkUuUpe5mHRB7kUKjtzfpPDa1vA== Date: Wed, 6 Jul 2022 15:18:41 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 97db56ac-8a06-49e2-6b7e-08da5f62d4a5 x-ms-traffictypediagnostic: AM0PR08MB2996:EE_|VE1EUR03FT031:EE_|GV2PR08MB7954:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Mp6BWV6yQY8y/+KocOvR4ddYSOwklnxJO4OtZYxCkkcDch6H9bRN4ASDUVStTA0Tzn86pkO+5gdAbew3Y9gG/D7VcFTPmz1dOjf2MRIf8mY22FjccdRKWVlf46WfPBbeKTjCn9osoefXplc+bZRZErptOv15wgKPhuFoZb28Dwdg2o6hhm+020wYf/sl75ktPzBXR7q6FXB5FoXv6oW54h5LtrxuGWk+6iuD+O3ph6vhM+soboFA9TaW+pct2f1I5kxc/yOIAT4+eGhjsr8fDtbLhSTM/eTI+kY+ECqfdmOsDZgaklKfMz39mp9DXwGk66Jw5hKx/UEy0m6jalos1aB6y369qPB2UMixSBIZlRM9VhAegPkvJgx2h9ABaJ+d/hvg4GQOwzS/2Wc0CYwg5M7UK3o/9EwkrQTe6+Mj0QnYy2FpAdUxbHNs/1OnLaE5Y5zpiJa+G+6xUgc5azpLTNDj4/tWJaBFkJuHVagGj9017j2afyC7tUYqWwm6EpY51PQEnPkPyRNasbtqAp1Qa4gue2VezSjgm5CPlDlb6CB3NpBDyvZLGFRNtTB7EwG8r2/w/ipT6xTP/Awq8LUAHR2M77XuRuyJXW+TKgPr5CvuRq02EtNLIsvDngKdGtjgZbpI/hu93q7cysFFyeRxJK3FS9YO60/FS+9JD1Wrpv8mXafmIo0CJMyiSyhqW9uR9lEee/yF6qi5A0OcZho0DiHlJ4hZH3T6fWhEMxddxS5wXiUprwodzEzUVicn3dx8H101NWg0cWlN6qIrf7kH0c8Xm5IeFtXXd0ixLNDD0Ioo8bebgFe3dRW9qFdpGahq X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(396003)(39860400002)(376002)(346002)(83380400001)(38070700005)(122000001)(38100700002)(30864003)(316002)(71200400001)(52536014)(8936002)(91956017)(5660300002)(76116006)(8676002)(66476007)(66446008)(64756008)(66946007)(66556008)(9686003)(186003)(26005)(2906002)(478600001)(6506007)(41300700001)(7696005)(6916009)(33656002)(55016003)(86362001)(579004); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2996 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8a6ff3ef-8abb-4888-3e74-08da5f62cf0c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: alNbBksZWO4SrBiqhd09J0TFC46aKfe2bvv3cyZL95tKJ/cl6JxbJOJWcanK+zgW7uVocA9wRL/N/xOl61rPwUsioQYD2etY3erliJ7mv61EdBD5CgF70SN55bOO/dBb4RrFWos61xpH2rGvfu7FfbCFQ9MhLV01D05OGTzcbpVtPv3CeB9UxknJEI6JJvWfl+/q7XGMu2edFkj7GyvWbjuCtoEgBxF1x956Pr9UDDHxbOm9tI4Od2/t0vgROoWvCxOJTTrl2qAxvL/dqz9OuYaRWxm92NpaGUOVGmmOmAjr4JnmtBUPI4k9adfmHQyBMsCtlmldo0Gu9IhU7+gdnk9VEZSthGwSGEzViBpKUlqLcGJfF0p48H9V/0sF1eJu9q9WMDD3OybyVWPc/aCz9Gcm/MWt9kVmeJa9XpRuvvPPHi735/zwP9ij0iguD5hLIRcVm8AGDh5ObtimDZcklyvRODfaYX9qcv/KlFjTAeWRSo3JuBBOhm1GsxbCuTdipaiWnXO9r8HlFoOrSinA57s9B7HB9A7oKVHnx6Fy7Yz3+KGUk8/mIdbdywQqHoFXeO+0UxLSp5y25afBg1VaDgIw+kigOmKRy0YwSBtTCzLeeUB1tFF5q8inhRcoPw3Lu5R+THMLgeYuWk4St9HKlWTEaSXQ3aB5jZIwl24O2fxrSBWgDHujOiuIjVUPDNTVVvIb18/BAJaaroyUiospTOQuNKKgdnrpgLAVo7nw21gRdnLMXoPtxJ87CMvjNB/UnwYpcaDPfHg9Re2mYQMIZaVcWOmML4N4cvd/ezgg5zneMswM4JVeqNWw9Ae1reoJ X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(346002)(136003)(376002)(396003)(39860400002)(40470700004)(46966006)(36840700001)(6916009)(316002)(2906002)(336012)(47076005)(40460700003)(86362001)(478600001)(186003)(33656002)(36860700001)(82740400003)(7696005)(5660300002)(41300700001)(81166007)(356005)(55016003)(6506007)(8936002)(8676002)(26005)(9686003)(52536014)(40480700001)(70206006)(83380400001)(82310400005)(30864003)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:18:50.3984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97db56ac-8a06-49e2-6b7e-08da5f62d4a5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB7954 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Replace atomic_increment, atomic_increment_val and atomic_increment_and_test with atomic_fetch_add_relaxed for counters. One case in sem_post.c uses release semantics. diff --git a/htl/pt-create.c b/htl/pt-create.c index ce52ed9f52210a4e4c7a049ebee817ec9ccfeeb1..14f02cd2b8a19e8581a170dfba2b948ef8304203 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -228,7 +228,7 @@ __pthread_create_internal (struct __pthread **thread, the number of threads from within the new thread isn't an option since this thread might return and call `pthread_exit' before the new thread runs. */ - atomic_increment (&__pthread_total); + atomic_fetch_add_relaxed (&__pthread_total, 1); /* Store a pointer to this thread in the thread ID lookup table. We could use __thread_setid, however, we only lock for reading as no diff --git a/include/atomic.h b/include/atomic.h index fd1a1eb0f87d288251d176d69246cff2d3422af7..492485597a12950d946691cb98b1b3ecbed7d592 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -187,23 +187,6 @@ #endif -#ifndef atomic_increment -# define atomic_increment(mem) atomic_add ((mem), 1) -#endif - - -#ifndef atomic_increment_val -# define atomic_increment_val(mem) (atomic_exchange_and_add ((mem), 1) + 1) -#endif - - -/* Add one to *MEM and return true iff it's now zero. */ -#ifndef atomic_increment_and_test -# define atomic_increment_and_test(mem) \ - (atomic_exchange_and_add ((mem), 1) + 1 == 0) -#endif - - #ifndef atomic_decrement # define atomic_decrement(mem) atomic_add ((mem), -1) #endif diff --git a/manual/ipc.texi b/manual/ipc.texi index 081b98fe29e0b3b5b7f4f916ad2085d170bd3825..f7cbdc3e09b0b4aea9a96ddcaf571c474024cc32 100644 --- a/manual/ipc.texi +++ b/manual/ipc.texi @@ -85,7 +85,7 @@ by @theglibc{}. @deftypefun int sem_wait (sem_t *@var{sem}); @safety{@prelim{}@mtsafe{}@assafe{}@acunsafe{@acucorrupt{}}} -@c atomic_increment (nwaiters) acucorrupt +@c atomic_fetch_add_relaxed (nwaiters) acucorrupt @c @c Given the use atomic operations this function seems @c to be AS-safe. It is AC-unsafe because there is still diff --git a/manual/llio.texi b/manual/llio.texi index 92bfd93e067ce2a782369084ed7dae099300f418..4e6e3fb672bb8ecbb1bb52faf3d70d9b7b33973f 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -2528,7 +2528,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c _dl_allocate_tls_init ok @c GET_DTV ok @c mmap ok -@c atomic_increment_val ok +@c atomic_fetch_add_relaxed ok @c munmap ok @c change_stack_perm ok @c mprotect ok @@ -2567,7 +2567,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c do_clone @asulock @ascuheap @aculock @acsmem @c PREPARE_CREATE ok @c lll_lock (pd->lock) @asulock @aculock -@c atomic_increment ok +@c atomic_fetch_add_relaxed ok @c clone ok @c atomic_decrement ok @c atomic_exchange_acquire ok diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 765b036873e181d6c49299c0ad08d5dbfcc05387..841ef2e2c6be2da8d1547cfb8bfcc03015154e58 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -128,45 +128,6 @@ do_test (void) ret = 1; } - mem = -1; - atomic_increment (&mem); - if (mem != 0) - { - puts ("atomic_increment test failed"); - ret = 1; - } - - mem = 2; - if (atomic_increment_val (&mem) != 3) - { - puts ("atomic_increment_val test failed"); - ret = 1; - } - - mem = 0; - if (atomic_increment_and_test (&mem) - || mem != 1) - { - puts ("atomic_increment_and_test test 1 failed"); - ret = 1; - } - - mem = 35; - if (atomic_increment_and_test (&mem) - || mem != 36) - { - puts ("atomic_increment_and_test test 2 failed"); - ret = 1; - } - - mem = -1; - if (! atomic_increment_and_test (&mem) - || mem != 0) - { - puts ("atomic_increment_and_test test 3 failed"); - ret = 1; - } - mem = 17; atomic_decrement (&mem); if (mem != 16) diff --git a/nptl/nptl_setxid.c b/nptl/nptl_setxid.c index aa863c7ea8122ea01d1aa4cffe101bbb7c11270c..3b7e2d434abe8a15145349d1a08a4e706061c74d 100644 --- a/nptl/nptl_setxid.c +++ b/nptl/nptl_setxid.c @@ -163,7 +163,7 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) /* If this failed, it must have had not started yet or else exited. */ if (!INTERNAL_SYSCALL_ERROR_P (val)) { - atomic_increment (&cmdp->cntr); + atomic_fetch_add_relaxed (&cmdp->cntr, 1); return 1; } else diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 1e6b385787aab5fa2f452de0cd2eae2b5f0fba83..6542c3183eda33b145aa80adcb620c7a19450aa2 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -759,7 +759,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, we momentarily store a false value; this doesn't matter because there is no kosher thing a signal handler interrupting us right here can do that cares whether the thread count is correct. */ - atomic_increment (&__nptl_nthreads); + atomic_fetch_add_relaxed (&__nptl_nthreads, 1); /* Our local value of stopped_start and thread_ran can be accessed at any time. The PD->stopped_start may only be accessed if we have diff --git a/nptl/sem_post.c b/nptl/sem_post.c index 9e5741753a741034db96cfff8b8978908fafc1f6..7ec21e92eb4c71d7f17764e96bc7603837f7522d 100644 --- a/nptl/sem_post.c +++ b/nptl/sem_post.c @@ -91,7 +91,7 @@ __old_sem_post (sem_t *sem) /* We must need to synchronize with consumers of this token, so the atomic increment must have release MO semantics. */ atomic_write_barrier (); - (void) atomic_increment_val (futex); + atomic_fetch_add_release (futex, 1); /* We always have to assume it is a shared semaphore. */ futex_wake (futex, 1, LLL_SHARED); return 0; diff --git a/nscd/cache.c b/nscd/cache.c index b66c35334a79a315ac9fd533df09ec097221d8e0..21af9a0f9550dfc7c1121fb5014cd80acdfcf696 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -192,7 +192,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet, /* We depend on this value being correct and at least as high as the real number of entries. */ - atomic_increment (&table->head->nentries); + atomic_fetch_add_relaxed (&table->head->nentries, 1); /* It does not matter that we are not loading the just increment value, this is just for statistics. */ diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 8e66fa2548e87c9b24cade41339c83f4cef7f2cf..d3e05e272a854e13c0e4d18594ea57336b8db2bf 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -425,7 +425,7 @@ __nscd_get_map_ref (request_type type, const char *name, 0)) cur = NO_MAPPING; else - atomic_increment (&cur->counter); + atomic_fetch_add_relaxed (&cur->counter, 1); } } diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h index 72a3b81642c1a23207054092d16bb856556cd897..6e454c5ceddd4e82b88b71203a94549bbb20ed20 100644 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h @@ -157,37 +157,6 @@ } \ }) -#define atomic_increment_and_test(mem) \ - ({ char __result; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("addq%.b %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("addq%.w %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("addq%.l %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %1,%2;" \ - " move%.l %R1,%R2;" \ - " addq%.l %#1,%R2;" \ - " addx%.l %5,%2;" \ - " seq %0;" \ - " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ - " jbne 1b" \ - : "=&dm" (__result), "=d" (__oldval), \ - "=&d" (__temp) \ - : "r" (__memp), "r" ((char *) __memp + 4), \ - "d" (0), "1" (__oldval) \ - : "memory"); \ - } \ - __result; }) - #define atomic_decrement_and_test(mem) \ ({ char __result; \ if (sizeof (*(mem)) == 1) \ diff --git a/sysdeps/microblaze/atomic-machine.h b/sysdeps/microblaze/atomic-machine.h index 871750e3cb4f193f610c4ccd804c8595eabbdc3a..4f94632c5184d3154b7b3b12cd9369d25008c2d8 100644 --- a/sysdeps/microblaze/atomic-machine.h +++ b/sysdeps/microblaze/atomic-machine.h @@ -173,45 +173,6 @@ __result; \ }) -#define __arch_atomic_increment_val_32(mem) \ - ({ \ - __typeof (*(mem)) __val; \ - int test; \ - __asm __volatile ( \ - " addc r0, r0, r0;" \ - "1: lwx %0, %3, r0;" \ - " addic %1, r0, 0;" \ - " bnei %1, 1b;" \ - " addi %0, %0, 1;" \ - " swx %0, %3, r0;" \ - " addic %1, r0, 0;" \ - " bnei %1, 1b;" \ - : "=&r" (__val), \ - "=&r" (test), \ - "=m" (*mem) \ - : "r" (mem), \ - "m" (*mem) \ - : "cc", "memory"); \ - __val; \ - }) - -#define __arch_atomic_increment_val_64(mem) \ - (abort (), (__typeof (*mem)) 0) - -#define atomic_increment_val(mem) \ - ({ \ - __typeof (*(mem)) __result; \ - if (sizeof (*(mem)) == 4) \ - __result = __arch_atomic_increment_val_32 (mem); \ - else if (sizeof (*(mem)) == 8) \ - __result = __arch_atomic_increment_val_64 (mem); \ - else \ - abort (); \ - __result; \ - }) - -#define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; }) - #define __arch_atomic_decrement_val_32(mem) \ ({ \ __typeof (*(mem)) __val; \ diff --git a/sysdeps/powerpc/atomic-machine.h b/sysdeps/powerpc/atomic-machine.h index 853bd8a75eaa429feb4a707069a8f5859943d103..10d94d6cbf0497f8d2b0f431efd9f79fb9b127e1 100644 --- a/sysdeps/powerpc/atomic-machine.h +++ b/sysdeps/powerpc/atomic-machine.h @@ -151,19 +151,6 @@ __val; \ }) -#define __arch_atomic_increment_val_32(mem) \ - ({ \ - __typeof (*(mem)) __val; \ - __asm __volatile ("1: lwarx %0,0,%2\n" \ - " addi %0,%0,1\n" \ - " stwcx. %0,0,%2\n" \ - " bne- 1b" \ - : "=&b" (__val), "=m" (*mem) \ - : "b" (mem), "m" (*mem) \ - : "cr0", "memory"); \ - __val; \ - }) - #define __arch_atomic_decrement_val_32(mem) \ ({ \ __typeof (*(mem)) __val; \ @@ -274,20 +261,6 @@ __result; \ }) -#define atomic_increment_val(mem) \ - ({ \ - __typeof (*(mem)) __result; \ - if (sizeof (*(mem)) == 4) \ - __result = __arch_atomic_increment_val_32 (mem); \ - else if (sizeof (*(mem)) == 8) \ - __result = __arch_atomic_increment_val_64 (mem); \ - else \ - abort (); \ - __result; \ - }) - -#define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; }) - #define atomic_decrement_val(mem) \ ({ \ __typeof (*(mem)) __result; \ diff --git a/sysdeps/powerpc/powerpc32/atomic-machine.h b/sysdeps/powerpc/powerpc32/atomic-machine.h index 33ff2aa071b93c7497e6c8ded8e0fbc33ce41722..5a82e75399615c40d02aca420116c6ac76e9d627 100644 --- a/sysdeps/powerpc/powerpc32/atomic-machine.h +++ b/sysdeps/powerpc/powerpc32/atomic-machine.h @@ -85,9 +85,6 @@ #define __arch_atomic_exchange_and_add_64_rel(mem, value) \ ({ abort (); (*mem) = (value); }) -#define __arch_atomic_increment_val_64(mem) \ - ({ abort (); (*mem)++; }) - #define __arch_atomic_decrement_val_64(mem) \ ({ abort (); (*mem)--; }) diff --git a/sysdeps/powerpc/powerpc64/atomic-machine.h b/sysdeps/powerpc/powerpc64/atomic-machine.h index cbaf01162a277519bdcf730c33d4e5526c3dcb39..7ac9ef6ab4c32550ba9de54873ace239757b6a77 100644 --- a/sysdeps/powerpc/powerpc64/atomic-machine.h +++ b/sysdeps/powerpc/powerpc64/atomic-machine.h @@ -181,19 +181,6 @@ __val; \ }) -#define __arch_atomic_increment_val_64(mem) \ - ({ \ - __typeof (*(mem)) __val; \ - __asm __volatile ("1: ldarx %0,0,%2\n" \ - " addi %0,%0,1\n" \ - " stdcx. %0,0,%2\n" \ - " bne- 1b" \ - : "=&b" (__val), "=m" (*mem) \ - : "b" (mem), "m" (*mem) \ - : "cr0", "memory"); \ - __val; \ - }) - #define __arch_atomic_decrement_val_64(mem) \ ({ \ __typeof (*(mem)) __val; \ diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index fe73fe3ba84db02b1d7188de8f29d55019a69ff3..fdb4d71cb5890272cec88d3af73aef463ff11c8b 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -72,8 +72,8 @@ static uint32_t nl_timestamp; uint32_t __bump_nl_timestamp (void) { - if (atomic_increment_val (&nl_timestamp) == 0) - atomic_increment (&nl_timestamp); + if (atomic_fetch_add_relaxed (&nl_timestamp, 1) + 1 == 0) + atomic_fetch_add_relaxed (&nl_timestamp, 1); return nl_timestamp; } @@ -309,7 +309,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, if (cache_valid_p ()) { data = cache; - atomic_increment (&cache->usecnt); + atomic_fetch_add_relaxed (&cache->usecnt, 1); } else { diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h index 3bf84d06bc875fca75b38b5ab01fca6683d390f7..2f45171240ce8d1970b101134a5c838b8a621cb9 100644 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/sh/atomic-machine.h @@ -299,5 +299,4 @@ abort (); \ __result; }) -#define atomic_increment_and_test(mem) atomic_add_zero((mem), 1) #define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1) diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 2abab58628e88bf2f5fc980d2de6b0dd556f6cd4..97d9d4a194a9d7deddbaa1781a1f9484a3e9232d 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -124,9 +124,7 @@ #define __arch_add_body(lock, pfx, apfx, mem, value) \ do { \ - if (__builtin_constant_p (value) && (value) == 1) \ - pfx##_increment (mem); \ - else if (__builtin_constant_p (value) && (value) == -1) \ + if (__builtin_constant_p (value) && (value) == -1) \ pfx##_decrement (mem); \ else if (sizeof (*mem) == 1) \ __asm __volatile (lock "addb %b1, %0" \ @@ -200,53 +198,6 @@ __result; }) -#define __arch_increment_body(lock, pfx, mem) \ - do { \ - if (sizeof (*mem) == 1) \ - __asm __volatile (lock "incb %b0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "incw %w0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "incl %0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "incq %q0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else \ - do_add_val_64_acq (pfx, mem, 1); \ - } while (0) - -#define atomic_increment(mem) __arch_increment_body (LOCK_PREFIX, __arch, mem) - -#define atomic_increment_and_test(mem) \ - ({ unsigned char __result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "incb %b0; sete %b1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "incw %w0; sete %w1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "incl %0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (LOCK_PREFIX "incq %q0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else \ - __atomic_link_error (); \ - __result; }) - - #define __arch_decrement_body(lock, pfx, mem) \ do { \ if (sizeof (*mem) == 1) \ From patchwork Wed Jul 6 15:20:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1653033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=yd5JBLNB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdNYB2NnXz9ryY for ; Thu, 7 Jul 2022 01:21:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D77193858032 for ; Wed, 6 Jul 2022 15:21:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D77193858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1657120875; bh=otLZInzl48DAa301Vd+9aKdlvCsfa0DCr81wsU9nIqY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yd5JBLNBxigdj1znY/5PB2Qrc+p6rM5pdqc2i5LDO83Eaa2qDOldmFlO/4T41c3V+ jrnlCXBvf6jvt6K94kCQMpJ6shprvqFquSLRmAy4HmTXQRi+OiHjSle/Mo0LlTdUgN iP5DqsMEAexBW8aq7/Y4EfvBA8uaWGJN2nt1uZNY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30074.outbound.protection.outlook.com [40.107.3.74]) by sourceware.org (Postfix) with ESMTPS id 555843858C39 for ; Wed, 6 Jul 2022 15:20:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 555843858C39 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=mmVJRC6xun0CvtlojezgFF//3PlYRD2CI8sEOqi5BPJZqbQlDFxwAcS5I6yzAXelhxcXMxz7Xjuz86tuE7J9oHKuy6SK1TG4yKzbuxB86z74GjknZEofwYCbWWkrdgDSKplR1vEgdHPRw0it+oe1BS922cyW4rBOplV5uv3Yl2csY8yGCYpgPGaYYK0PJAKMkVZCmYUsmfIQI2CINnW6CXax0809tHxd1jST2NMUTKeUHKTu86CnJj9RoQ/pWvOuuUuUZbAw0h9qCJoOmaM16pbWO9Ij0L84/RLWYYR9rWx9WVDAh4zgIi4KWAYJjgXd77zilNF3IwJ8RO5CBTAviA== ARC-Message-Signature: i=2; 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=otLZInzl48DAa301Vd+9aKdlvCsfa0DCr81wsU9nIqY=; b=TovCvd3xuV/bugqYKmR6tVdVlcqEAWhdZILz7oazzmxfgPpq2VScoAJvQnx3OmkOY2IEqkHEFobMZL3NtqJKDa8yPceTaWWkjHDIhwDurljhQWzr7SgnYrTnv5evSwmbfCs6lfqDhUoWL5+78o8KKGsFSunI4lMqxNQ+ZpiaCNbhrSlfn3iKv0gADy3qou641/JiEqJlgTQ5YIOHceRsYIYUaTCu4114r7fFDYtznRhPJsuW5AejT5aoEOfLcb0mVmGdCMakLT1T2DwF5AJI/SIPm8rccsM5s1Kwia/kQhSiCSvV13pnZnnXnWAvCuN7C/be9DCpDcLooTSd4EV5wQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8PR04CA0114.eurprd04.prod.outlook.com (2603:10a6:20b:31e::29) by AS8PR08MB6408.eurprd08.prod.outlook.com (2603:10a6:20b:33a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Wed, 6 Jul 2022 15:20:54 +0000 Received: from AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::c0) by AS8PR04CA0114.outlook.office365.com (2603:10a6:20b:31e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:20:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT006.mail.protection.outlook.com (10.152.16.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Wed, 6 Jul 2022 15:20:54 +0000 Received: ("Tessian outbound 0ba541f03a2a:v122"); Wed, 06 Jul 2022 15:20:53 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d318d3e93d09f368 X-CR-MTA-TID: 64aa7808 Received: from 0d190add73c2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EA3076E7-0EF7-468E-870D-4952E83CC976.1; Wed, 06 Jul 2022 15:20:47 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0d190add73c2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Jul 2022 15:20:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afxAQ9AIWLmCLzjjedn+Ud6ftIuf54B50zJq6rqx+4Lo3oKbTxFMvM4TiLfV9yYS6TxfbK8n/4/ON5SZ6AZW9nhx5wdGSwVN96xLkShv/4nBC34qCD6+RlLxdXaEhOCuzNqkdny6avyMlNHPWBcEm0YB0k4JqWKA9hGTlmIViGrSRpRh/XgjrYk1Y+H4DVQvuyQYvBF1NTsaGBJICQ6lwjC6p1Q+C3rcB1C/vX7jBNHHdjz0YXLy6MsrsJxXtiN9wTidjwFJ/0hNMSUhzTMTTX9xgiz3PQBettGV/yw6ninNa2O3mQmAyR4UzaaYQvX3dgKAQvkAFTMRIt6BTWeYxg== 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=otLZInzl48DAa301Vd+9aKdlvCsfa0DCr81wsU9nIqY=; b=GZrHtbCRZat/s+17sdMQ+tQR8+Svf5L6mK9saHjNwoZNx3yzcxb15tdKanvzzMWkJtEz9n2d3bsmhQOA2XioXAK6xrCAOg19k0NCNDK4oNtfZSCX+Wb0qeWO7IpLOeeD4z3BFJWUyGM8+FVJzwk7d44Cp6gnkNrT8YLKOT7R9dva4GcmDzAe9l7EzpWGT8Ix8osiTwgz3xeF6+/eRfYdWyXHNaCF+5byXOEGz3QMldnxuzJ1zNMhEfjy+GunpPQC8aDklqL7sCoJhUwYcjVIj9SAByXLarGUQ7xVGqPfRD/5gpw2r2F2kNho34vxLsjRI+Rg5H1xS+hJ0hfyBA2NHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM0PR08MB2996.eurprd08.prod.outlook.com (2603:10a6:208:5b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Wed, 6 Jul 2022 15:20:45 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::845f:5b9c:410a:f581%5]) with mapi id 15.20.5417.015; Wed, 6 Jul 2022 15:20:45 +0000 To: 'GNU C Library' Subject: [PATCH 7/7] Remove atomic_decrement/decrement_val/decrement_and_test Thread-Topic: [PATCH 7/7] Remove atomic_decrement/decrement_val/decrement_and_test Thread-Index: AQHYkUvEWJAA9gTVfkeQBAmeKCzfkw== Date: Wed, 6 Jul 2022 15:20:44 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 5fabbd16-c82c-4cec-64a2-08da5f631e59 x-ms-traffictypediagnostic: AM0PR08MB2996:EE_|AM5EUR03FT006:EE_|AS8PR08MB6408:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bhqn+Y5m35AdhwqPEun3aM77kM20rBu+pcE3Gd3hyGJPHj/W80sjq+ATI1z08rRIwvbGGDybNI1aHR46x+aWTdYhLr424pUv/cRSmMGgordbTEDBH6zUN26olqWgoq61Wpj5epFwoaYWIMzNz7jLKRYKPJEodweQhDMA3Z9WpKb9flvztrrvyPfa2+AeIPS7BFVE+wdox49/x7vPMKUtRLO03kYY2Qif8slc0dnH2gf0y5J9RhCeE9AfiMGNrPLpJGLjDQnVIt4a8vpNQI1yapsxVCcFUUX8f9Te5zxr9YOAmni0EWi1JFGzcnUb3bovyAQr5U46GZUA0W0QvLCbiYhQgmoXxM9bA/zj/hOkpGrUkY7iKOFdisQYdH6chDXVbyL0o0oLwYiOCaTmyaZTF7zi/0bGvj1KuYNAgqg1FzCG7Eafz3WkVfxMq1wzouxiVUVsPe+YUGGE9aLq3bLOoCJsK18+0XMl8m1Q862W+nPpFgtriIFdcSxTPmNQyDb4njrnGdn8LsgDRsWiumhCqIVJZ/4s4p6a33nW5Sh0GNIAL7g6JYkO6A115eq4z+l+RoJGhBqiC5+SAloMyA8eE4rkXw3DmaN/zyAFWvcmPSc4eNIiKBBiOI4fLQ0KXuZEAwXFSqEJuPUsLjq2s9+mOWOieMr6PkUaCkjT9BcTIeCjI+Z1sAMcUWodvMJwxjbrB4RwpUTPa7nCjvv0lDg/aPyBnyk/7rWtKZZBCg6p05R2WIr7bCTwPtohncIaH5URtitFZhwSQ7h/9a6sYGyLSONcVQFbBUfJLgwYjQfYua2uZas44Vbr0hLpmKGN1ypimG0OtbRVrInfY4Thyu+T+Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(396003)(39860400002)(376002)(346002)(83380400001)(38070700005)(122000001)(38100700002)(30864003)(316002)(71200400001)(52536014)(8936002)(91956017)(5660300002)(76116006)(8676002)(66476007)(66446008)(64756008)(66946007)(66556008)(9686003)(186003)(26005)(2906002)(478600001)(6506007)(41300700001)(7696005)(6916009)(33656002)(55016003)(86362001)(21314003)(559001)(579004); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2996 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2617f4d1-89d5-4a4d-2bfe-08da5f6318de X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oSV+Z5HajEhKD34nH0zn9YyVz70HThpk+aAUc2WoAa1a57HpYIxCix+ItrlDFJ4CuAaEibGWBM75PaHJklPPjqaVIshOrzP0xOx2DdIPCIIlFlwP/1pe5ocGE6mZexEo1h9AaxP0TGuGRe/cO0uwSilZbY+NEm3pSelXMhFmCYbYplJoiGK2wtAXkmISiKKeqKHUBq73oqW4ol0BXswrRSD+6pAWbJQKotuA8LBmpP4uXIyk+xmwZrtwlazKHiDRSHDvcL67oRcz9jWy1Q6ZOUr8xwKf2lPDPexo8s8KhYBYMl383IBzjGCp+UysiFRqJJGVkBMXT8kxVqlVgSpAdoqasZoOW9mSgTPib3k1EuX/BmTcpM9FQrJC1FVYSK5PQ0/ItNT3//CUWfpn8bJsSKwVz0GLMaDmxgy8KtmfNGGbIlSXKJYA9+1wPJ2N55o0rjIxJnuu74COQSkc/RW0peKHT4Wyku1g9+5+h6xNTB/806DyaGNkPcygCvPf9a7x92oNQPe5b+j2ag0MgSBJSOxkI0BTmy4+SSoTBlR29MmzWvrjwGXDHu1TpzmA0EurdeI13llCnSK/ex3uFCR+jnO5zwBV1bzK2HpOdVZxnK4Wd1Qx1HWZDot0uvXCK1F9shswColWD29EfvGA6JEfVqUIKG5p4O/njPF/OIrr0ZS0pbkacuG+7Dlz+88Boh0MxBT3FjmqVxAfZFeu0pAcw57sJvU2YeRmtYYEEJ+OHt9F7UeQpyXSxLZ/kGCDL7zV3LoTSg35GR5TGiD4Day17HFK3fF8NJzXHZoDPVhtOavCPl3MwhQCLe7JFHySk9Eu71Yd7mhPMuZ6U+ao3VKaRbAx9rEOtfKmexEgyTULfls= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(376002)(346002)(396003)(136003)(39860400002)(40470700004)(36840700001)(46966006)(82310400005)(8676002)(316002)(40480700001)(2906002)(55016003)(30864003)(8936002)(70586007)(5660300002)(70206006)(41300700001)(52536014)(6916009)(33656002)(478600001)(82740400003)(81166007)(356005)(186003)(7696005)(86362001)(9686003)(26005)(36860700001)(6506007)(336012)(40460700003)(47076005)(83380400001)(21314003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 15:20:54.1093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fabbd16-c82c-4cec-64a2-08da5f631e59 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6408 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Replace atomic_decrement, atomic_decrement_val and atomic_decrement_and_test with atomic_fetch_add_relaxed. diff --git a/htl/pt-create.c b/htl/pt-create.c index 14f02cd2b8a19e8581a170dfba2b948ef8304203..5d37edbbffb16b7cbb6db133016653227fc45f47 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -262,7 +262,7 @@ failed_starting: } __pthread_setid (pthread->thread, NULL); - atomic_decrement (&__pthread_total); + atomic_fetch_add_relaxed (&__pthread_total, -1); failed_sigstate: __pthread_sigstate_destroy (pthread); failed_setup: diff --git a/htl/pt-dealloc.c b/htl/pt-dealloc.c index c776e3471dc376977ca7058f0d143f0a842d5799..86bbb3091fbd3758b06294ca705dc774cf8bf0eb 100644 --- a/htl/pt-dealloc.c +++ b/htl/pt-dealloc.c @@ -33,7 +33,7 @@ extern pthread_mutex_t __pthread_free_threads_lock; void __pthread_dealloc (struct __pthread *pthread) { - if (!atomic_decrement_and_test (&pthread->nr_refs)) + if (atomic_fetch_add_relaxed (&pthread->nr_refs, -1) != 1) return; /* Withdraw this thread from the thread ID lookup table. */ diff --git a/htl/pt-exit.c b/htl/pt-exit.c index f0759c8738e6da4c8e0ba47f6d15720203f6954e..3c0a8c52f34ed64b94ce71a0764512cb76351a3a 100644 --- a/htl/pt-exit.c +++ b/htl/pt-exit.c @@ -50,7 +50,7 @@ __pthread_exit (void *status) /* Decrease the number of threads. We use an atomic operation to make sure that only the last thread calls `exit'. */ - if (atomic_decrement_and_test (&__pthread_total)) + if (atomic_fetch_add_relaxed (&__pthread_total, -1) == 1) /* We are the last thread. */ exit (0); diff --git a/include/atomic.h b/include/atomic.h index 50778792e444238dddceb95386afd3d70450b2a1..0f31ea77ba2095ea461bf84f89c9987317f63b35 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -182,27 +182,6 @@ } while (0) #endif -#ifndef atomic_add -# define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value)) -#endif - - -#ifndef atomic_decrement -# define atomic_decrement(mem) atomic_add ((mem), -1) -#endif - - -#ifndef atomic_decrement_val -# define atomic_decrement_val(mem) (atomic_exchange_and_add ((mem), -1) - 1) -#endif - - -/* Subtract 1 from *MEM and return true iff it's now zero. */ -#ifndef atomic_decrement_and_test -# define atomic_decrement_and_test(mem) \ - (atomic_exchange_and_add ((mem), -1) == 1) -#endif - /* Decrement *MEM if it is > 0, and return the old value. */ #ifndef atomic_decrement_if_positive diff --git a/manual/ipc.texi b/manual/ipc.texi index f7cbdc3e09b0b4aea9a96ddcaf571c474024cc32..be74664af9c146dd3024b080e90b7ca9834b14ef 100644 --- a/manual/ipc.texi +++ b/manual/ipc.texi @@ -89,7 +89,7 @@ by @theglibc{}. @c @c Given the use atomic operations this function seems @c to be AS-safe. It is AC-unsafe because there is still -@c a window between atomic_decrement and the pthread_push +@c a window between atomic_fetch_add_relaxed and the pthread_push @c of the handler that undoes that operation. A cancellation @c at that point would fail to remove the process from the @c waiters count. diff --git a/manual/llio.texi b/manual/llio.texi index 4e6e3fb672bb8ecbb1bb52faf3d70d9b7b33973f..1b801ee817db2935d8866894be23ffa516690ca3 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -2569,7 +2569,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c lll_lock (pd->lock) @asulock @aculock @c atomic_fetch_add_relaxed ok @c clone ok -@c atomic_decrement ok +@c atomic_fetch_add_relaxed ok @c atomic_exchange_acquire ok @c lll_futex_wake ok @c deallocate_stack dup @@ -2614,7 +2614,7 @@ aiocb64}, since the LFS transparently replaces the old interface. @c free @ascuheap @acsmem @c libc_thread_freeres @c libc_thread_subfreeres ok -@c atomic_decrement_and_test ok +@c atomic_fetch_add_relaxed ok @c td_eventword ok @c td_eventmask ok @c atomic_compare_exchange_bool_acq ok diff --git a/manual/memory.texi b/manual/memory.texi index abc867eaebff732b2d7cc086d9f5e3430d425295..110e736a64c667988f4ca2fe92deb409225a4a88 100644 --- a/manual/memory.texi +++ b/manual/memory.texi @@ -397,7 +397,7 @@ this function is in @file{stdlib.h}. @c mutex_lock (list_lock) dup @asulock @aculock @c atomic_write_barrier ok @c mutex_unlock (list_lock) @aculock -@c atomic_decrement ok +@c atomic_fetch_add_relaxed ok @c reused_arena @asulock @aculock @c reads&writes next_to_use and iterates over arena next without guards @c those are harmless as long as we don't drop arenas from the diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c index 67073c23c34126b87a6049b8d9ecd6cf2d9d23bc..2d1172a64d86cc81af49158085a84429c3a8f0dd 100644 --- a/misc/tst-atomic.c +++ b/misc/tst-atomic.c @@ -96,68 +96,6 @@ do_test (void) ret = 1; } - mem = 2; - if (atomic_exchange_and_add (&mem, 11) != 2 - || mem != 13) - { - puts ("atomic_exchange_and_add test failed"); - ret = 1; - } - - mem = 2; - if (atomic_exchange_and_add_acq (&mem, 11) != 2 - || mem != 13) - { - puts ("atomic_exchange_and_add test failed"); - ret = 1; - } - - mem = 2; - if (atomic_exchange_and_add_rel (&mem, 11) != 2 - || mem != 13) - { - puts ("atomic_exchange_and_add test failed"); - ret = 1; - } - - mem = 17; - atomic_decrement (&mem); - if (mem != 16) - { - puts ("atomic_decrement test failed"); - ret = 1; - } - - if (atomic_decrement_val (&mem) != 15) - { - puts ("atomic_decrement_val test failed"); - ret = 1; - } - - mem = 0; - if (atomic_decrement_and_test (&mem) - || mem != -1) - { - puts ("atomic_decrement_and_test test 1 failed"); - ret = 1; - } - - mem = 15; - if (atomic_decrement_and_test (&mem) - || mem != 14) - { - puts ("atomic_decrement_and_test test 2 failed"); - ret = 1; - } - - mem = 1; - if (! atomic_decrement_and_test (&mem) - || mem != 0) - { - puts ("atomic_decrement_and_test test 3 failed"); - ret = 1; - } - mem = 1; if (atomic_decrement_if_positive (&mem) != 1 || mem != 0) diff --git a/nptl/cond-perf.c b/nptl/cond-perf.c index 9c9488e2743f17eb4beeaadf45ef83a38a9f9bf9..baf69e6d34fdb3ffef97b32fb9db422077a0359b 100644 --- a/nptl/cond-perf.c +++ b/nptl/cond-perf.c @@ -24,7 +24,7 @@ cons (void *arg) do { - if (atomic_decrement_and_test (&ntogo)) + if (atomic_fetch_add_relaxed (&ntogo, -1) == 1) { pthread_mutex_lock (&mut2); alldone = true; diff --git a/nptl/nptl_setxid.c b/nptl/nptl_setxid.c index 3b7e2d434abe8a15145349d1a08a4e706061c74d..301809d200d1ac6c89fbf100e553c5713f326ed7 100644 --- a/nptl/nptl_setxid.c +++ b/nptl/nptl_setxid.c @@ -88,7 +88,7 @@ __nptl_setxid_sighandler (int sig, siginfo_t *si, void *ctx) self->setxid_futex = 1; futex_wake (&self->setxid_futex, 1, FUTEX_PRIVATE); - if (atomic_decrement_val (&xidcmd->cntr) == 0) + if (atomic_fetch_add_relaxed (&xidcmd->cntr, -1) == 1) futex_wake ((unsigned int *) &xidcmd->cntr, 1, FUTEX_PRIVATE); } libc_hidden_def (__nptl_setxid_sighandler) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 6542c3183eda33b145aa80adcb620c7a19450aa2..ad84eeda2362e2a6b9e0f8d85911afa52d3ce373 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -489,7 +489,7 @@ start_thread (void *arg) the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */ atomic_fetch_or_acquire (&pd->cancelhandling, 1 << EXITING_BIT); - if (__glibc_unlikely (atomic_decrement_and_test (&__nptl_nthreads))) + if (__glibc_unlikely (atomic_fetch_add_relaxed (&__nptl_nthreads, -1) == 1)) /* This was the last thread. */ exit (0); @@ -861,7 +861,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, NOTES above). */ /* Oops, we lied for a second. */ - atomic_decrement (&__nptl_nthreads); + atomic_fetch_add_relaxed (&__nptl_nthreads, -1); /* Free the resources. */ __nptl_deallocate_stack (pd); diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index fee2a15dcc323258cecd45c5fb8e472da9161792..ca9e6def1a88ff14c5e8b39f0e236aa8a30f95ae 100644 --- a/nscd/nscd-client.h +++ b/nscd/nscd-client.h @@ -421,7 +421,7 @@ __nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle) return -1; } - if (atomic_decrement_val (&map->counter) == 0) + if (atomic_fetch_add_relaxed (&map->counter, -1) == 1) __nscd_unmap (map); } diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c index a99a4d8142b89521f3ca1759f42d5d88e1103f61..8e4650ebaedc6d79bd5ccda6721551b0227dbbb5 100644 --- a/nscd/nscd_getai.c +++ b/nscd/nscd_getai.c @@ -198,7 +198,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c index 3636c031ec9403c7b447ebc52eecb2c60d74740f..bde3b588a01274730e1b1d817dfff62fd4f60c15 100644 --- a/nscd/nscd_getgr_r.c +++ b/nscd/nscd_getgr_r.c @@ -312,7 +312,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 9becb620335d14d7becebe6c29ad96cc4e7463ee..31d13580a11e64792d6f02ecd7437884d4436eb3 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -440,7 +440,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c index 20986f44332fca42d2f43794b4c365f6b3968cae..82fdd17d8c39287a9d450ff25802116028dc9475 100644 --- a/nscd/nscd_getpw_r.c +++ b/nscd/nscd_getpw_r.c @@ -225,7 +225,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c index 42b875d024c674a6c46dd28be8308a8d5d650ca6..de843b33631e2c57ac4e0192c6f1027c586cf329 100644 --- a/nscd/nscd_getserv_r.c +++ b/nscd/nscd_getserv_r.c @@ -365,7 +365,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index d3e05e272a854e13c0e4d18594ea57336b8db2bf..fc41bfdb6eebb880d6132ea5cf409ca657570f82 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -390,7 +390,7 @@ __nscd_get_mapping (request_type type, const char *key, struct mapped_database *oldval = *mappedp; *mappedp = result; - if (oldval != NULL && atomic_decrement_val (&oldval->counter) == 0) + if (oldval != NULL && atomic_fetch_add_relaxed (&oldval->counter, -1) == 1) __nscd_unmap (oldval); return result; diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c index dfce76a06090d5bd2869f8a239bdef51866bd854..47b6deb0699eaa984691388d146ae5e01ddd83ab 100644 --- a/nscd/nscd_initgroups.c +++ b/nscd/nscd_initgroups.c @@ -166,7 +166,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c index 7e51dd3d941e383ab97bc0f70dd4dda65c340e0b..11b7f3214c2fb08f2e08df86f0d984e7bfc9bda2 100644 --- a/nscd/nscd_netgroup.c +++ b/nscd/nscd_netgroup.c @@ -148,7 +148,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap) if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } @@ -272,7 +272,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user, if ((gc_cycle & 1) != 0 || ++nretries == 5 || retval == -1) { /* nscd is just running gc now. Disable using the mapping. */ - if (atomic_decrement_val (&mapped->counter) == 0) + if (atomic_fetch_add_relaxed (&mapped->counter, -1) == 1) __nscd_unmap (mapped); mapped = NO_MAPPING; } diff --git a/sysdeps/aarch64/atomic-machine.h b/sysdeps/aarch64/atomic-machine.h index 459deeec18713a374bbe186bf84b0c366896a8d7..a7a600c86fa8ac6496d04a36c779542f76e7d7c9 100644 --- a/sysdeps/aarch64/atomic-machine.h +++ b/sysdeps/aarch64/atomic-machine.h @@ -103,28 +103,6 @@ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \ mem, new, old, __ATOMIC_RELEASE) -/* Atomically add value and return the previous (unincremented) value. */ - -# define __arch_exchange_and_add_8_int(mem, value, model) \ - __atomic_fetch_add (mem, value, model) - -# define __arch_exchange_and_add_16_int(mem, value, model) \ - __atomic_fetch_add (mem, value, model) - -# define __arch_exchange_and_add_32_int(mem, value, model) \ - __atomic_fetch_add (mem, value, model) - -# define __arch_exchange_and_add_64_int(mem, value, model) \ - __atomic_fetch_add (mem, value, model) - -# define atomic_exchange_and_add_acq(mem, value) \ - __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \ - __ATOMIC_ACQUIRE) - -# define atomic_exchange_and_add_rel(mem, value) \ - __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \ - __ATOMIC_RELEASE) - /* Barrier macro. */ #define atomic_full_barrier() __sync_synchronize() diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h index 6e454c5ceddd4e82b88b71203a94549bbb20ed20..8460fb61072dce030957b029d7c180de13089481 100644 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h @@ -124,66 +124,3 @@ : "memory"); \ } \ __result; }) - -#define atomic_add(mem, value) \ - (void) ({ if (sizeof (*(mem)) == 1) \ - __asm __volatile ("add%.b %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("add%.w %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("add%.l %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %0,%1;" \ - " move%.l %R0,%R1;" \ - " add%.l %R2,%R1;" \ - " addx%.l %2,%1;" \ - " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ - " jbne 1b" \ - : "=d" (__oldval), "=&d" (__temp) \ - : "d" ((__typeof (*(mem))) (value)), \ - "r" (__memp), "r" ((char *) __memp + 4), \ - "0" (__oldval) \ - : "memory"); \ - } \ - }) - -#define atomic_decrement_and_test(mem) \ - ({ char __result; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("subq%.b %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("subq%.w %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("subq%.l %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %1,%2;" \ - " move%.l %R1,%R2;" \ - " subq%.l %#1,%R2;" \ - " subx%.l %5,%2;" \ - " seq %0;" \ - " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ - " jbne 1b" \ - : "=&dm" (__result), "=d" (__oldval), \ - "=&d" (__temp) \ - : "r" (__memp), "r" ((char *) __memp + 4), \ - "d" (0), "1" (__oldval) \ - : "memory"); \ - } \ - __result; }) diff --git a/sysdeps/microblaze/atomic-machine.h b/sysdeps/microblaze/atomic-machine.h index 4f94632c5184d3154b7b3b12cd9369d25008c2d8..5781b4440bf22a747fb90c4e7cd5476f14fb8573 100644 --- a/sysdeps/microblaze/atomic-machine.h +++ b/sysdeps/microblaze/atomic-machine.h @@ -172,42 +172,3 @@ abort (); \ __result; \ }) - -#define __arch_atomic_decrement_val_32(mem) \ - ({ \ - __typeof (*(mem)) __val; \ - int test; \ - __asm __volatile ( \ - " addc r0, r0, r0;" \ - "1: lwx %0, %3, r0;" \ - " addic %1, r0, 0;" \ - " bnei %1, 1b;" \ - " rsubi %0, %0, 1;" \ - " swx %0, %3, r0;" \ - " addic %1, r0, 0;" \ - " bnei %1, 1b;" \ - : "=&r" (__val), \ - "=&r" (test), \ - "=m" (*mem) \ - : "r" (mem), \ - "m" (*mem) \ - : "cc", "memory"); \ - __val; \ - }) - -#define __arch_atomic_decrement_val_64(mem) \ - (abort (), (__typeof (*mem)) 0) - -#define atomic_decrement_val(mem) \ - ({ \ - __typeof (*(mem)) __result; \ - if (sizeof (*(mem)) == 4) \ - __result = __arch_atomic_decrement_val_32 (mem); \ - else if (sizeof (*(mem)) == 8) \ - __result = __arch_atomic_decrement_val_64 (mem); \ - else \ - abort (); \ - __result; \ - }) - -#define atomic_decrement(mem) ({ atomic_decrement_val (mem); (void) 0; }) diff --git a/sysdeps/nptl/libc_start_call_main.h b/sysdeps/nptl/libc_start_call_main.h index a9e85f2b098dfc6790d719bba9662e428ab237e6..c10a16b2c4a61e74f6bf18396935b87208df4f7e 100644 --- a/sysdeps/nptl/libc_start_call_main.h +++ b/sysdeps/nptl/libc_start_call_main.h @@ -65,7 +65,7 @@ __libc_start_call_main (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), /* One less thread. Decrement the counter. If it is zero we terminate the entire process. */ result = 0; - if (! atomic_decrement_and_test (&__nptl_nthreads)) + if (atomic_fetch_add_relaxed (&__nptl_nthreads, -1) != 1) /* Not much left to do but to exit the thread, not the process. */ while (1) INTERNAL_SYSCALL_CALL (exit, 0); diff --git a/sysdeps/powerpc/atomic-machine.h b/sysdeps/powerpc/atomic-machine.h index 10d94d6cbf0497f8d2b0f431efd9f79fb9b127e1..f2114322f53699009aea29b9503492b1d5a03e2e 100644 --- a/sysdeps/powerpc/atomic-machine.h +++ b/sysdeps/powerpc/atomic-machine.h @@ -151,19 +151,6 @@ __val; \ }) -#define __arch_atomic_decrement_val_32(mem) \ - ({ \ - __typeof (*(mem)) __val; \ - __asm __volatile ("1: lwarx %0,0,%2\n" \ - " subi %0,%0,1\n" \ - " stwcx. %0,0,%2\n" \ - " bne- 1b" \ - : "=&b" (__val), "=m" (*mem) \ - : "b" (mem), "m" (*mem) \ - : "cr0", "memory"); \ - __val; \ - }) - #define __arch_atomic_decrement_if_positive_32(mem) \ ({ int __val, __tmp; \ __asm __volatile ("1: lwarx %0,0,%3\n" \ @@ -261,21 +248,6 @@ __result; \ }) -#define atomic_decrement_val(mem) \ - ({ \ - __typeof (*(mem)) __result; \ - if (sizeof (*(mem)) == 4) \ - __result = __arch_atomic_decrement_val_32 (mem); \ - else if (sizeof (*(mem)) == 8) \ - __result = __arch_atomic_decrement_val_64 (mem); \ - else \ - abort (); \ - __result; \ - }) - -#define atomic_decrement(mem) ({ atomic_decrement_val (mem); (void) 0; }) - - /* Decrement *MEM if it is > 0, and return the old value. */ #define atomic_decrement_if_positive(mem) \ ({ __typeof (*(mem)) __result; \ diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h index 6d4f8bdf1a9a96153c86c7a7fc9a796bc4feac7b..582d67db61e89d654862d9e15665f2fec94a1202 100644 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/sh/atomic-machine.h @@ -150,104 +150,3 @@ (void) __value; \ } \ __result; }) - -#define atomic_add(mem, value) \ - (void) ({ __typeof (*(mem)) __tmp, __value = (value); \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.b @%1,r2\n\ - add %0,r2\n\ - mov.b r2,@%1\n\ - 1: mov r1,r15"\ - : "=&r" (__tmp) : "u" (mem), "0" (__value) \ - : "r0", "r1", "r2", "memory"); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.w @%1,r2\n\ - add %0,r2\n\ - mov.w r2,@%1\n\ - 1: mov r1,r15"\ - : "=&r" (__tmp) : "u" (mem), "0" (__value) \ - : "r0", "r1", "r2", "memory"); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.l @%1,r2\n\ - add %0,r2\n\ - mov.l r2,@%1\n\ - 1: mov r1,r15"\ - : "=&r" (__tmp) : "u" (mem), "0" (__value) \ - : "r0", "r1", "r2", "memory"); \ - else \ - { \ - __typeof (*(mem)) oldval; \ - __typeof (mem) memp = (mem); \ - do \ - oldval = *memp; \ - while (__arch_compare_and_exchange_val_64_acq \ - (memp, oldval + __value, oldval) == oldval); \ - (void) __value; \ - } \ - }) - -#define atomic_add_zero(mem, value) \ - ({ unsigned char __result; \ - __typeof (*(mem)) __tmp, __value = (value); \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.b @%2,r2\n\ - add %1,r2\n\ - mov.b r2,@%2\n\ - 1: mov r1,r15\n\ - tst r2,r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.w @%2,r2\n\ - add %1,r2\n\ - mov.w r2,@%2\n\ - 1: mov r1,r15\n\ - tst r2,r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("\ - mova 1f,r0\n\ - mov r15,r1\n\ - .align 2\n\ - mov #(0f-1f),r15\n\ - 0: mov.l @%2,r2\n\ - add %1,r2\n\ - mov.l r2,@%2\n\ - 1: mov r1,r15\n\ - tst r2,r2\n\ - movt %0"\ - : "=r" (__result), "=&r" (__tmp) : "u" (mem), "1" (__value) \ - : "r0", "r1", "r2", "t", "memory"); \ - else \ - abort (); \ - __result; }) - -#define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1) diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 2f180abe9e682f9e64b471d091e455e192b156ba..2e06877034def3cc3c1cecb128cb770ac02acd78 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -30,9 +30,6 @@ #ifdef __x86_64__ # define __HAVE_64B_ATOMICS 1 # define SP_REG "rsp" -# define SEG_REG "fs" -# define BR_CONSTRAINT "q" -# define IBR_CONSTRAINT "iq" #else /* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the i386 psABI supplement provides only 4-byte alignment for uint64_t @@ -40,9 +37,6 @@ atomics on this platform. */ # define __HAVE_64B_ATOMICS 0 # define SP_REG "esp" -# define SEG_REG "gs" -# define BR_CONSTRAINT "r" -# define IBR_CONSTRAINT "ir" #endif #define ATOMIC_EXCHANGE_USES_CAS 0 @@ -51,122 +45,6 @@ #define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ (! __sync_bool_compare_and_swap (mem, oldval, newval)) - -#ifdef __x86_64__ -# define do_exchange_and_add_val_64_acq(pfx, mem, value) 0 -# define do_add_val_64_acq(pfx, mem, value) do { } while (0) -#else -/* XXX We do not really need 64-bit compare-and-exchange. At least - not in the moment. Using it would mean causing portability - problems since not many other 32-bit architectures have support for - such an operation. So don't define any code for now. If it is - really going to be used the code below can be used on Intel Pentium - and later, but NOT on i486. */ -# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ - ({ __typeof (*mem) ret = *(mem); \ - __atomic_link_error (); \ - ret = (newval); \ - ret = (oldval); \ - ret; }) - -# define do_exchange_and_add_val_64_acq(pfx, mem, value) \ - ({ __typeof (value) __addval = (value); \ - __typeof (*mem) __result; \ - __typeof (mem) __memp = (mem); \ - __typeof (*mem) __tmpval; \ - __result = *__memp; \ - do \ - __tmpval = __result; \ - while ((__result = pfx##_compare_and_exchange_val_64_acq \ - (__memp, __result + __addval, __result)) == __tmpval); \ - __result; }) - -# define do_add_val_64_acq(pfx, mem, value) \ - { \ - __typeof (value) __addval = (value); \ - __typeof (mem) __memp = (mem); \ - __typeof (*mem) __oldval = *__memp; \ - __typeof (*mem) __tmpval; \ - do \ - __tmpval = __oldval; \ - while ((__oldval = pfx##_compare_and_exchange_val_64_acq \ - (__memp, __oldval + __addval, __oldval)) == __tmpval); \ - } -#endif - - -#define __arch_exchange_and_add_body(lock, pfx, mem, value) \ - ({ __typeof (*mem) __result; \ - __typeof (value) __addval = (value); \ - if (sizeof (*mem) == 1) \ - __asm __volatile (lock "xaddb %b0, %1" \ - : "=q" (__result), "=m" (*mem) \ - : "0" (__addval), "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "xaddw %w0, %1" \ - : "=r" (__result), "=m" (*mem) \ - : "0" (__addval), "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "xaddl %0, %1" \ - : "=r" (__result), "=m" (*mem) \ - : "0" (__addval), "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "xaddq %q0, %1" \ - : "=r" (__result), "=m" (*mem) \ - : "0" ((int64_t) cast_to_integer (__addval)), \ - "m" (*mem)); \ - else \ - __result = do_exchange_and_add_val_64_acq (pfx, (mem), __addval); \ - __result; }) - -#define atomic_exchange_and_add(mem, value) \ - __sync_fetch_and_add (mem, value) - -#define __arch_decrement_body(lock, pfx, mem) \ - do { \ - if (sizeof (*mem) == 1) \ - __asm __volatile (lock "decb %b0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (lock "decw %w0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (lock "decl %0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else if (__HAVE_64B_ATOMICS) \ - __asm __volatile (lock "decq %q0" \ - : "=m" (*mem) \ - : "m" (*mem)); \ - else \ - do_add_val_64_acq (pfx, mem, -1); \ - } while (0) - -#define atomic_decrement(mem) __arch_decrement_body (LOCK_PREFIX, __arch, mem) - -#define atomic_decrement_and_test(mem) \ - ({ unsigned char __result; \ - if (sizeof (*mem) == 1) \ - __asm __volatile (LOCK_PREFIX "decb %b0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 2) \ - __asm __volatile (LOCK_PREFIX "decw %w0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else if (sizeof (*mem) == 4) \ - __asm __volatile (LOCK_PREFIX "decl %0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - else \ - __asm __volatile (LOCK_PREFIX "decq %q0; sete %1" \ - : "=m" (*mem), "=qm" (__result) \ - : "m" (*mem)); \ - __result; }) - - /* We don't use mfence because it is supposedly slower due to having to provide stronger guarantees (e.g., regarding self-modifying code). */ #define atomic_full_barrier() \