Re: [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
- From
Nicolas Pitre <nico@fluxnic.net>
- Date
- Nov 5, 2009, 20:36 UTC
- Message-ID
- <alpine.LFD.2.00.0911051527570.10340@xanadu.home>
- In-Reply-To
- <16cee31f0911051209jcc490e2pabeab9a1b6e3b11d@mail.gmail.com>
On Thu, 5 Nov 2009, Andrzej K. Haczewski wrote:
Show 14 quoted lines
> 2009/11/5 Nicolas Pitre <nico@fluxnic.net>:
> > On Thu, 5 Nov 2009, Andrzej K. Haczewski wrote:
> >
> >> +static unsigned __stdcall win32_start_routine(void *arg)
> >> +{
> >> + pthread_t *thread = arg;
> >> + thread->value = thread->start_routine(thread->arg);
> >> + return 0;
> >> +}
> >
> > I suppose you could reuse thread->arg for both the argument and the
> > returned value to save a word.
>
> You're right! J6t committed already, what can I do now?Just post a replacement patch.
Show 6 quoted lines
> > Why are you casting thread->handle here? Why not simply declaring it as > > a HANDLE? > > Just to silence MSVC warnings. WaitForSingleObject requires HANDLE, > _beginthreadex() returns uintptr_t. It's just a matter of where would > I put cast ;).
Wonderful. One could wonder why Windows can't have coherent interfaces...
Well, given that all existing usages in the tree (run-command.c and compat/mingw.c) already cast the _beginthreadex() return value instead, then that might be a good idea to follow the same model.
Nicolas