git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] win32: pthread_cond_init should return a value

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 7, 2025, 00:18 UTC
Message-ID
<xmqqwm2znnzc.fsf@gitster.g>
In-Reply-To
<xmqqecps5f8u.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 34 quoted lines
> "AZero13 via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> From: Greg Funni <gfunni234@gmail.com>
>>
>> This value is not checked, but it must return to match POSIX
>>
>> Signed-off-by: Greg Funni <gfunni234@gmail.com>
>> ---
>>     win32: pthread_cond_init should return a value
>>     
>>     This value is not checked, but it must return to match POSIX
>> ...
>> -#define pthread_cond_init(a,b) InitializeConditionVariable((a))
>> +#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
>
> This is tricky and I like it.
>
> Because InitializeConditionVariable() returns void, and return_0()
> is defined as such:
>
>     static inline int return_0(int i) { return 0; }
>
> you cannot directly pass InitializeConditionVariable() to it, so you
> use a comma operator and pass 0 to return_0().  Because the type of
> the comma operator with mixed operands is the type of the rightmost
> operand, the type of "InitializeConditionVariable((a)), 0" is type
> of "0", so return_0() would happily take it as an int, and returns
> 0.
>
> This should work correctly, but it still is tricky and yucky.
>
> You may not have to use return_0(), but OK.
>
> Will queue.  Thanks.

As I do not do Windows, I was hoping somebody more clueful than myself on the platform would give an Ack to this patch, but we saw nothing. I'll mark the topic for 'next'. I do not anticipate breakage but if there were something fishy, hopefully we will hear quickly enough.

Previous: Junio C Hamano
Message 6 of 6 in “win32: pthread_cond_wait should return a value”
  1. win32: pthread_cond_wait should return a valueAZero13 via GitGitGadget, Nov 18, 2025
  2. win32: pthread_cond_wait should return a valueAZero13 via GitGitGadget, Nov 18, 2025
  3. Junio C HamanoNov 18, 2025
  4. win32: pthread_cond_init should return a valueAZero13 via GitGitGadget, Nov 20, 2025
  5. Junio C HamanoNov 21, 2025
  6. Junio C HamanoDec 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.