Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 May 2023 10:23:20 -0400
From: Rich Felker <dalias@...c.org>
To: Jens Gustedt <Jens.Gustedt@...ia.fr>
Cc: musl@...ts.openwall.com
Subject: Re: [C23 divers headers 03/17] C23: add call_once to stdlib.h

On Mon, Apr 17, 2023 at 11:09:20AM +0200, Jens Gustedt wrote:
> Since C23, call_once, once_flag and ONCE_FLAG_INIT are also accessible
> even if the platform does not have the threads option. Add them to the
> header.
> 
> The identifiers once_flag and ONCE_FLAG_INIT were not reserved in C17
> if the header threads.h was not included, so this potentially creates
> naming conflicts.
> ---
>  include/stdlib.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/stdlib.h b/include/stdlib.h
> index 475190bf..c635d99b 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -172,6 +172,10 @@ long double strtold_l(const char *__restrict, char **__restrict, struct __locale
>  #endif
>  #endif
>  
> +#define ONCE_FLAG_INIT 0
> +typedef int once_flag;
> +void call_once(once_flag *, void (*)(void));
> +
>  #ifdef __cplusplus
>  }
>  #endif
> -- 
> 2.34.1

This is borderline whether it matters (the name is unlikely to clash
and eventually we will only support namespace rules for latest C) but
it's probably better to guard it with C version check.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.