c11/threads: fix build on c23
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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 <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38298>
This commit is contained in:
Dave Airlie 2025-11-07 13:14:56 +10:00
parent 1889f1a779
commit 179e744f75
2 changed files with 4 additions and 1 deletions

View file

@ -46,12 +46,13 @@ impl_thrd_routine(void *p)
/*--------------- 7.25.2 Initialization functions ---------------*/ /*--------------- 7.25.2 Initialization functions ---------------*/
// 7.25.2.1 // 7.25.2.1
#ifndef __once_flag_defined
void void
call_once(once_flag *flag, void (*func)(void)) call_once(once_flag *flag, void (*func)(void))
{ {
pthread_once(flag, func); pthread_once(flag, func);
} }
#endif
/*------------- 7.25.3 Condition variable functions -------------*/ /*------------- 7.25.3 Condition variable functions -------------*/
// 7.25.3.1 // 7.25.3.1

View file

@ -118,8 +118,10 @@ typedef pthread_cond_t cnd_t;
typedef pthread_t thrd_t; typedef pthread_t thrd_t;
typedef pthread_key_t tss_t; typedef pthread_key_t tss_t;
typedef pthread_mutex_t mtx_t; typedef pthread_mutex_t mtx_t;
#ifndef __once_flag_defined
typedef pthread_once_t once_flag; typedef pthread_once_t once_flag;
# define ONCE_FLAG_INIT PTHREAD_ONCE_INIT # define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
#endif
# ifdef PTHREAD_DESTRUCTOR_ITERATIONS # ifdef PTHREAD_DESTRUCTOR_ITERATIONS
# define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS # define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
# else # else