Add once_flag, ONCE_FLAG_INIT and call_once to stdlib.h for C23

Collin Funk collin.funk1@gmail.com
Wed Oct 1 03:40:10 GMT 2025


Joseph Myers <josmyers@redhat.com> writes:

> This doesn't seem a significant enough feature to be worth mentioning
> in NEWS.

Fine with me to keep this out of NEWS, since the C11 threads.h never
caught on, as far as I can tell. I'm surprised the C committee decided
to even make this change.

If someone else thinks it is important enough to mention in NEWS we can
add it later.

> +#ifndef __once_flag_defined
> +# define __once_flag_defined 1
> +
> +# include <bits/thread-shared-types.h>
> +

Can we format this like:

   #ifndef __once_flag_defined
   #define __once_flag_defined 1

   #include <bits/thread-shared-types.h>

>From a quick glance most headers follow that style. I assume they were
written before the wiki page detailing the code style [1].

Patch looks good though and passes all tests on x86_64 for me.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin

[1] https://sourceware.org/glibc/wiki/Style_and_Conventions#Nested_C_Preprocessor_Directives


More information about the Libc-alpha mailing list