[PATCH] libdw: Don't use ATOMIC_VAR_INIT
Aaron Merey
amerey@redhat.com
Tue Nov 19 00:02:27 GMT 2024
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
More information about the Elfutils-devel
mailing list