--- /dev/null
+/* Define once_flag and ONCE_FLAG_INIT.
+ Copyright (C) 2018-2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef __once_flag_defined
+#define __once_flag_defined 1
+
+#include <bits/thread-shared-types.h>
+
+typedef __once_flag once_flag;
+#define ONCE_FLAG_INIT __ONCE_FLAG_INIT
+
+#endif
@code{call_once} with the same @code{flag} variable.
@end deftypefun
+These definitions are from C11, where they appear in @file{threads.h}.
+In C23, they appear in @file{stdlib.h} as well as in @file{threads.h}.
+
@node ISO C Mutexes
@subsection Mutexes
extern int ttyslot (void) __THROW;
#endif
+#if __GLIBC_USE (ISOC23)
+# include <bits/types/once_flag.h>
+
+/* Call function __FUNC exactly once, even if invoked from several threads.
+ All calls must be made with the same __FLAGS object. */
+extern void call_once (once_flag *__flag, void (*__func)(void));
+#endif
+
#include <bits/stdlib-float.h>
/* Define some macros helping to catch buffer overflows. */
__BEGIN_DECLS
#include <bits/thread-shared-types.h>
+#include <bits/types/once_flag.h>
#include <bits/types/struct_timespec.h>
#if (!defined __STDC_VERSION__ \
mtx_timed = 2
};
-typedef __once_flag once_flag;
-#define ONCE_FLAG_INIT __ONCE_FLAG_INIT
-
typedef union
{
char __size[__SIZEOF_PTHREAD_MUTEX_T];