[cfe-dev] [libc++] Porting libc++ to Windows

David Chisnall David.Chisnall at cl.cam.ac.uk
Thu Jul 2 01:38:54 PDT 2015


On 2 Jul 2015, at 08:59, Fulvio Esposito <fulvio.esposito at live.it> wrote:
> 
> - Your pthread implementation uses functions requiring Windows Vista or later, is WinXP not a target? Also, I had to manually set _WIN32_WINNT to 0x600 in __config because mingw-w64 defaults to 0x503 or something like that.

You’re likely to see a lot of overhead on Windows if you don’t use the Vista (actually, I think, Windows Server 2003, though I could be wrong) stuff for synchronisation - the older mutexes are global kernel objects with no adaptive mutex fast path for the uncontended case.

I wonder if it actually makes sense to wrap Win32 stuff as pthread before again wrapping it as C++ standard library functionality though.  It’s a bit bad currently that we leak the pthread stuff into the global namespace when a user does #include <thread> on UNIX[1], but on Windows it’s likely to cause some confusion to user code.  We should probably stick some wrappers for the required pthread and win32 thread functionality in the libc++ internal namespace and then call them from the std:: things, rather than trying to make one look like the other.

David

[1] We leak a lot of headers that we probably shouldn’t like this - I’ve had issues as a result when porting code to libstdc++, which is a lot more careful about visibility.  On the plus side, at least it’s porting from libc++ to libstdc++ that’s hard and not the other way around...



More information about the cfe-dev mailing list