What's the reason Boost.Asio tss_ptr doesn't use __declspec(thread) on Windows?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

What's the reason Boost.Asio tss_ptr doesn't use __declspec(thread) on Windows?

Boost - Dev mailing list

I've noticed that Boost.Asio's tss_ptr implementation doesn't use __declspec(thread) on Windows, except when compiling for WinRT.
Instead it uses the win_tss_ptr implementation - which will cause a crash when there's no free TLS index.
(There are static tss_ptr instances and loading a DLL where a ctor of a static variables throws a C++ exception seems to cause a crash -- no surprise there).
AFAIK using implicit TLS via __declspec(thread) should fix this so that loading a DLL either works or fails gracefully.

One problem that I know of with implicit TLS is that it fails catastrophically on Windows versions before Vista. Since WinRT wasn't available on pre-Vista versions, this might be a reason to restrict it to WinRT.
But I don't know if there are/were other reasons to restrict use of implicit TLS to WinRT.
So... is there another reason?

If there's no other reason, that would be great, because we don't have to support pre-Vista versions. Meaning we could simply patch Boost.Asio to use implicit TLS for MSVC in general.

Paul Groke

Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost