Merge issue-38-targets follow-up: Windows runtime qualification and MinGW portability
This commit is contained in:
commit
08a40ad5fc
8 files changed
+73
-27
No files matched your search
@@ -97,7 +97,16 @@ struct HookControl {
|
||||
std::condition_variable drain_cv;
|
||||
};
|
||||
|
||||
inline thread_local std::vector<const HookControl*> t_active_hook_controls;
|
||||
// Per-thread stack of hook controls currently executing. A function-local
|
||||
// thread_local keeps a single definition across TUs; a namespace-scope
|
||||
// `inline thread_local` makes MinGW emit one TLS init function per TU and
|
||||
// fails to link with duplicate symbols.
|
||||
[[nodiscard]] inline std::vector<const HookControl*>&
|
||||
active_hook_controls() noexcept
|
||||
{
|
||||
static thread_local std::vector<const HookControl*> controls;
|
||||
return controls;
|
||||
}
|
||||
|
||||
struct HookCallScope {
|
||||
const HookControl* control{nullptr};
|
||||
@@ -105,14 +114,15 @@ struct HookCallScope {
|
||||
explicit HookCallScope(const HookControl* ctrl) : control(ctrl)
|
||||
{
|
||||
if (control != nullptr) {
|
||||
t_active_hook_controls.push_back(control);
|
||||
active_hook_controls().push_back(control);
|
||||
}
|
||||
}
|
||||
|
||||
~HookCallScope() noexcept
|
||||
{
|
||||
if (control != nullptr && !t_active_hook_controls.empty()) {
|
||||
t_active_hook_controls.pop_back();
|
||||
auto& controls = active_hook_controls();
|
||||
if (control != nullptr && !controls.empty()) {
|
||||
controls.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +131,7 @@ struct HookCallScope {
|
||||
|
||||
[[nodiscard]] static bool is_active_on_thread(const HookControl* ctrl) noexcept
|
||||
{
|
||||
for (const auto* entry : t_active_hook_controls) {
|
||||
for (const auto* entry : active_hook_controls()) {
|
||||
if (entry == ctrl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user