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

Fulvio Esposito fulvio.esposito at live.it
Thu Jul 2 02:19:16 PDT 2015


Hi David,

----------------------------------------
> Subject: Re: [cfe-dev] [libc++] Porting libc++ to Windows
> From: David.Chisnall at cl.cam.ac.uk
>
> 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.
>

just to put things in perspective, what I was talking about is about the work Dan Albert did. I haven't written any code yet, but I really appreciate some guidance. Dan provided a wrapper for pthread calls used by libc++, and in doing so he used a few functions from the Windows SDK available from Vista onward (he also guarded the case of _WIN32_WINNT being less than 0x600 with an error, hence I had to define the constant in mingw64 to avoid compilation errors). I'm not sure all of them come with Win Server 2003 though.

> 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.

I like your idea and am willing to give it a try. In this case I think it would be more helpful to first define the thin wrapper around pthread and reimplement std:: stuff on top of that, and then to provide the Win32 implementation. How does it sound? 

Fulvio 		 	   		  



More information about the cfe-dev mailing list