-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Split the monolithic __threading_support header #79654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___THREAD_SUPPORT_H | ||
#define _LIBCPP___THREAD_SUPPORT_H | ||
|
||
#include <__config> | ||
|
||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
# pragma GCC system_header | ||
#endif | ||
|
||
/* | ||
|
||
// | ||
// The library supports multiple implementations of the basic threading functionality. | ||
// The following functionality must be provided by any implementation: | ||
// | ||
|
||
using __libcpp_timespec_t = ...; | ||
|
||
// | ||
// Mutex | ||
// | ||
using __libcpp_mutex_t = ...; | ||
#define _LIBCPP_MUTEX_INITIALIZER ... | ||
|
||
using __libcpp_recursive_mutex_t = ...; | ||
|
||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t*); | ||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t*); | ||
|
||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t*); | ||
int __libcpp_mutex_destroy(__libcpp_mutex_t*); | ||
|
||
// | ||
// Condition Variable | ||
// | ||
using __libcpp_condvar_t = ...; | ||
#define _LIBCPP_CONDVAR_INITIALIZER ... | ||
|
||
int __libcpp_condvar_signal(__libcpp_condvar_t*); | ||
int __libcpp_condvar_broadcast(__libcpp_condvar_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t*, __libcpp_mutex_t*); | ||
_LIBCPP_NO_THREAD_SAFETY_ANALYSIS | ||
int __libcpp_condvar_timedwait(__libcpp_condvar_t*, __libcpp_mutex_t*, __libcpp_timespec_t*); | ||
int __libcpp_condvar_destroy(__libcpp_condvar_t*); | ||
|
||
// | ||
// Execute once | ||
// | ||
using __libcpp_exec_once_flag = ...; | ||
#define _LIBCPP_EXEC_ONCE_INITIALIZER ... | ||
|
||
int __libcpp_execute_once(__libcpp_exec_once_flag*, void (*__init_routine)()); | ||
|
||
// | ||
// Thread id | ||
// | ||
using __libcpp_thread_id = ...; | ||
|
||
bool __libcpp_thread_id_equal(__libcpp_thread_id, __libcpp_thread_id); | ||
bool __libcpp_thread_id_less(__libcpp_thread_id, __libcpp_thread_id); | ||
|
||
// | ||
// Thread | ||
// | ||
#define _LIBCPP_NULL_THREAD ... | ||
using __libcpp_thread_t = ...; | ||
|
||
bool __libcpp_thread_isnull(const __libcpp_thread_t*); | ||
int __libcpp_thread_create(__libcpp_thread_t*, void* (*__func)(void*), void* __arg); | ||
__libcpp_thread_id __libcpp_thread_get_current_id(); | ||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t*); | ||
int __libcpp_thread_join(__libcpp_thread_t*); | ||
int __libcpp_thread_detach(__libcpp_thread_t*); | ||
void __libcpp_thread_yield(); | ||
void __libcpp_thread_sleep_for(const chrono::nanoseconds&); | ||
|
||
// | ||
// Thread local storage | ||
// | ||
#define _LIBCPP_TLS_DESTRUCTOR_CC ... | ||
using __libcpp_tls_key = ...; | ||
|
||
int __libcpp_tls_create(__libcpp_tls_key*, void (*__at_exit)(void*)); | ||
void* __libcpp_tls_get(__libcpp_tls_key); | ||
int __libcpp_tls_set(__libcpp_tls_key, void*); | ||
|
||
*/ | ||
|
||
#if !defined(_LIBCPP_HAS_NO_THREADS) | ||
|
||
# if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | ||
# include <__thread/support/external.h> | ||
# elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
# include <__thread/support/pthread.h> | ||
# elif defined(_LIBCPP_HAS_THREAD_API_C11) | ||
# include <__thread/support/c11.h> | ||
# elif defined(_LIBCPP_HAS_THREAD_API_WIN32) | ||
# include <__thread/support/windows.h> | ||
# else | ||
# error "No threading API was selected" | ||
# endif | ||
|
||
#endif // !_LIBCPP_HAS_NO_THREADS | ||
|
||
#endif // _LIBCPP___THREAD_SUPPORT_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just include the
<__external_threading>
header directly? There doesn't seem to be much reason not to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am tempted to leave it as-is just cause the CI is passing and there are other changes I want to land on top. I can do a follow-up patch.