[PATCH v2] libstdc++: On Windows, retrieve thread-local variables via functions
LIU Hao
lh_mouse@126.com
Mon Dec 8 14:18:10 GMT 2025
在 2025-12-8 22:03, Jonathan Wakely 写道:
> In C++14 I would declare it like this:
>
> std::add_lvalue_reference_t<void (*)()>
> __get_once_call() noexcept;
>
> But for C++11 we don't have add_lvalue_reference, so we need the
> slightly uglier form:
>
> std::add_lvalue_reference<void (*)()>::type
> __get_once_call() noexcept;
Well, in my own code I have stuff like
template<typename... _Args>
using _Vfn = void (_Args...);
so this could be
_Vfn<>*
__get_once_call() noexcept;
If there's no such thing in libstdc++, I'm okay with this change.
> It occurs to me that we would only need the first #ifdef group if it
> did something like the errno trick:
>
> #define __once_callable __get_once_callable()
> #define __once_call __get_once_call
>
> (and #undef at the end of the file).
>
> That way all the later code wouldn't need changes, it would continue
> to use __once_callable and __once_call but those would expand to calls
> to the getters. I don't love the use of macros with lowercase names,
> but it reduces the diffs between Windows and other targets to just
> that first #ifdef group.
>
> What do you think?
Actually I thought about this a little, and right, I don't like these macros either. The first patch
tried to avoid macros in a wrong way. If these names are available as macros, I'm fine with this change too.
Do I have to send a third patch?
--
Best regards,
LIU Hao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20251208/a9a7b914/attachment-0001.sig>
More information about the Libstdc++
mailing list