Skip to content

[libc++] Fix __threading_support when used with C11 threading #66780

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 19, 2023

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.

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.
@ldionne ldionne requested a review from a team as a code owner September 19, 2023 14:36
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2023

@llvm/pr-subscribers-libcxx

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/66780.diff

1 Files Affected:

  • (modified) libcxx/include/__threading_support (+1-1)
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

@ldionne
Copy link
Member Author

ldionne commented Sep 19, 2023

I'll ship this since it's a small change that is obviously correct and the CI is happy. This fixes some downstream issues (that's how this patch came about).

@ldionne ldionne merged commit e7a7a16 into llvm:main Sep 19, 2023
@ldionne ldionne deleted the review/fix-once-flag branch September 19, 2023 22:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants