Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <65deacef8e879e0278ca6bcfd0d7c0a4fd7387a7.1685522953.git.Jens.Gustedt@inria.fr>
Date: Wed, 31 May 2023 11:22:50 +0200
From: Jens Gustedt <Jens.Gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: [C23 divers headers 03/17] C23: add call_once to stdlib.h

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 we protect this with the
version macro.
---
 include/stdlib.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/stdlib.h b/include/stdlib.h
index 475190bf..0e66f84a 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -172,6 +172,12 @@ long double strtold_l(const char *__restrict, char **__restrict, struct __locale
 #endif
 #endif
 
+#if __STDC_VERSION__ >= 202000L
+#define ONCE_FLAG_INIT 0
+typedef int once_flag;
+void call_once(once_flag *, void (*)(void));
+#endif
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.34.1

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.