Message ID | 20241118185624.586091-1-mark@klomp.org |
---|---|
State | Committed |
Headers |
Return-Path: <elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60B063858D35 for <patchwork@sourceware.org>; Mon, 18 Nov 2024 18:56:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60B063858D35 X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id ECD103858D21 for <elfutils-devel@sourceware.org>; Mon, 18 Nov 2024 18:56:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECD103858D21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ECD103858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731956191; cv=none; b=xsBae39xkEB3GIxua3ThihFBKvbWPLUP8ZE/PQfWI2v1P+DA15yYUUhzBXfmAlKy3lMRrwWuSlJY4DdOcadDTy03C8Yyv50tEkaDGz1QYelhTYNeU8j0bzBv3ziE4euVmqs3AnsPU5DjZ3+fARYTWwkdeVbLCfj9MIFdCgDfcQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731956191; c=relaxed/simple; bh=H1LnLfglw0tGY6PW73daB0sh7hUfsHWOqbB36KJj9sw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XapMgPYZi+aqGip9/sj5qzfdE5zeGbNnEwuvCRWBO5pzFKVb3bd0JUNs64Ku9SdmxZhq30SrmpCx4mrVQFaKc1e7lsN324F7wMnUYmZXXczRqA0zelpGcLiydibSzz0gRdC+Avwxr/WZP8l3j/4TPi7ivvJ/Caq67YwP71bx+kg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECD103858D21 Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id E8386303AA0D; Mon, 18 Nov 2024 19:56:29 +0100 (CET) Received: by r6.localdomain (Postfix, from userid 1000) id 83C7834037E; Mon, 18 Nov 2024 19:56:29 +0100 (CET) From: Mark Wielaard <mark@klomp.org> To: elfutils-devel@sourceware.org Cc: Mark Wielaard <mark@klomp.org> Subject: [PATCH] libdw: Don't use ATOMIC_VAR_INIT Date: Mon, 18 Nov 2024 19:56:24 +0100 Message-ID: <20241118185624.586091-1-mark@klomp.org> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Post: <mailto:elfutils-devel@sourceware.org> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org |
Series |
libdw: Don't use ATOMIC_VAR_INIT
|
|
Commit Message
Mark Wielaard
Nov. 18, 2024, 6:56 p.m. UTC
ATOMIC_VAR_INIT was introduced in C11, but not deemed necessary to
implement atomics. So deprecated in C17 and removed in C23. Normal
initialization syntax should be sufficient.
* libdw/libdw_alloc.c (next_id): Initialize to zero without
using ATOMIC_VAR_INIT.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libdw/libdw_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Mark, On Mon, Nov 18, 2024 at 1:56 PM Mark Wielaard <mark@klomp.org> wrote: > > ATOMIC_VAR_INIT was introduced in C11, but not deemed necessary to > implement atomics. So deprecated in C17 and removed in C23. Normal > initialization syntax should be sufficient. > > * libdw/libdw_alloc.c (next_id): Initialize to zero without > using ATOMIC_VAR_INIT. > > Signed-off-by: Mark Wielaard <mark@klomp.org> > --- > libdw/libdw_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libdw/libdw_alloc.c b/libdw/libdw_alloc.c > index b3e533434939..adc729f525f2 100644 > --- a/libdw/libdw_alloc.c > +++ b/libdw/libdw_alloc.c > @@ -45,7 +45,7 @@ > > #define THREAD_ID_UNSET ((size_t) -1) > static __thread size_t thread_id = THREAD_ID_UNSET; > -static atomic_size_t next_id = ATOMIC_VAR_INIT(0); > +static atomic_size_t next_id = 0; > > struct libdw_memblock * > __libdw_alloc_tail (Dwarf *dbg) > -- > 2.47.0 > LGTM. Aaron Ballman has noted [1] that no implementation of atomics or embedded locks has depended on the use of this macro. Aaron [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1138r0.pdf
Hi Aaron, On Mon, Nov 18, 2024 at 07:02:27PM -0500, Aaron Merey wrote: > LGTM. Aaron Ballman has noted [1] that no implementation of atomics or > embedded locks has depended on the use of this macro. Thanks, pushed. > [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1138r0.pdf
diff --git a/libdw/libdw_alloc.c b/libdw/libdw_alloc.c index b3e533434939..adc729f525f2 100644 --- a/libdw/libdw_alloc.c +++ b/libdw/libdw_alloc.c @@ -45,7 +45,7 @@ #define THREAD_ID_UNSET ((size_t) -1) static __thread size_t thread_id = THREAD_ID_UNSET; -static atomic_size_t next_id = ATOMIC_VAR_INIT(0); +static atomic_size_t next_id = 0; struct libdw_memblock * __libdw_alloc_tail (Dwarf *dbg)