From 6e3646c81143477008e448d3b0b5c349169e4112 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Fri, 7 Nov 2025 13:14:56 +1000
Subject: [PATCH] c11/threads: fix build on fedora 44.

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.
---
 src/c11/impl/threads_posix.c | 2 +-
 src/c11/threads.h            | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/c11/impl/threads_posix.c b/src/c11/impl/threads_posix.c
index 3b8692482bb..4769c029bad 100644
--- a/src/c11/impl/threads_posix.c
+++ b/src/c11/impl/threads_posix.c
@@ -49,7 +49,7 @@ impl_thrd_routine(void *p)
 void
 call_once(once_flag *flag, void (*func)(void))
 {
-    pthread_once(flag, func);
+    pthread_once((pthread_once_t *)flag, func);
 }
 
 
diff --git a/src/c11/threads.h b/src/c11/threads.h
index dbcb3459a9b..053636f6674 100644
--- a/src/c11/threads.h
+++ b/src/c11/threads.h
@@ -118,8 +118,11 @@ 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
+#define __once_flag_defined 1
 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
-- 
2.51.1

