[libcxx-commits] [libcxx] [libc++] Fix __threading_support when used with C11 threading (PR #66780)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 19 07:36:49 PDT 2023


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/66780

Since we are defining these typedefs inside namespace std, we need to refer to ::once_flag (the C Standard Library version). Otherwise 'once_flag' refers to 'std::once_flag', and that's not something we can pass to the C Standard Library '::call_once()' function later on.

>From 992be0081965ea684eecd11034137983a0a726ac Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 19 Sep 2023 10:34:20 -0400
Subject: [PATCH] [libc++] Fix __threading_support when used with C11 threading

Since we are defining these typedefs inside namespace std, we need to
refer to ::once_flag (the C Standard Library version). Otherwise
'once_flag' refers to 'std::once_flag', and that's not something we
can pass to the C Standard Library '::call_once()' function later on.
---
 libcxx/include/__threading_support | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index eaa402abae351b6..ccbcc652d9e50a6 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -102,7 +102,7 @@ typedef cnd_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER {}
 
 // Execute once
-typedef once_flag __libcpp_exec_once_flag;
+typedef ::once_flag __libcpp_exec_once_flag;
 #define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT
 
 // Thread id



More information about the libcxx-commits mailing list