From 675a63111549cfb8b20b4c4f2f19c214084ea2be Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 7 Nov 2025 13:14:56 +1000 Subject: [PATCH] c11/threads: fix build on c23 C23/glibc is now including once_init in stdlib.h https://patchwork.sourceware.org/project/glibc/patch/78061085-f04a-0c45-107b-5a8a15521083@redhat.com/#213088 Just fix up our use of it. Cc: mesa-stable Reviewed-by: Yonggang Luo Part-of: (cherry picked from commit 179e744f7577d98df7c79d7324c22acfb32a0154) --- .pick_status.json | 2 +- src/c11/impl/threads_posix.c | 3 ++- src/c11/threads.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f16b9e686ba..6cfd563e8ee 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -814,7 +814,7 @@ "description": "c11/threads: fix build on c23", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/c11/impl/threads_posix.c b/src/c11/impl/threads_posix.c index 3b8692482bb..6db8c42f08c 100644 --- a/src/c11/impl/threads_posix.c +++ b/src/c11/impl/threads_posix.c @@ -46,12 +46,13 @@ impl_thrd_routine(void *p) /*--------------- 7.25.2 Initialization functions ---------------*/ // 7.25.2.1 +#ifndef __once_flag_defined void call_once(once_flag *flag, void (*func)(void)) { pthread_once(flag, func); } - +#endif /*------------- 7.25.3 Condition variable functions -------------*/ // 7.25.3.1 diff --git a/src/c11/threads.h b/src/c11/threads.h index dbcb3459a9b..c849f385e30 100644 --- a/src/c11/threads.h +++ b/src/c11/threads.h @@ -118,8 +118,10 @@ typedef pthread_cond_t cnd_t; typedef pthread_t thrd_t; typedef pthread_key_t tss_t; typedef pthread_mutex_t mtx_t; +#ifndef __once_flag_defined typedef pthread_once_t once_flag; # define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#endif # ifdef PTHREAD_DESTRUCTOR_ITERATIONS # define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS # else