git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] win32: pthread_cond_wait should return a value
@ 2025-11-18  0:59 AZero13 via GitGitGadget
  2025-11-18 15:42 ` [PATCH v2] " AZero13 via GitGitGadget
  0 siblings, 1 reply; 6+ messages in thread
From: AZero13 via GitGitGadget @ 2025-11-18  0:59 UTC (permalink / raw)
  To: git; +Cc: AZero13, AZero13

From: AZero13 <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_wait should return a value
    
    This value is not checked, but it must return to match POSIX

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v1
Pull-Request: https://github.com/git/git/pull/2103

 compat/win32/pthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index e2b5c4f64c..000604cdf6 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;
 
 #define pthread_cond_t CONDITION_VARIABLE
 
-#define pthread_cond_init(a,b) InitializeConditionVariable((a))
+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
 #define pthread_cond_destroy(a) do {} while (0)
 #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
 #define pthread_cond_signal WakeConditionVariable

base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] win32: pthread_cond_wait should return a value
  2025-11-18  0:59 [PATCH] win32: pthread_cond_wait should return a value AZero13 via GitGitGadget
@ 2025-11-18 15:42 ` AZero13 via GitGitGadget
  2025-11-18 18:17   ` Junio C Hamano
  2025-11-20 21:43   ` [PATCH v3] win32: pthread_cond_init " AZero13 via GitGitGadget
  0 siblings, 2 replies; 6+ messages in thread
From: AZero13 via GitGitGadget @ 2025-11-18 15:42 UTC (permalink / raw)
  To: git; +Cc: AZero13, Greg Funni

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_wait should return a value
    
    This value is not checked, but it must return to match POSIX

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v2
Pull-Request: https://github.com/git/git/pull/2103

Range-diff vs v1:

 1:  643a9b7eae ! 1:  a2d9ec97f1 win32: pthread_cond_wait should return a value
     @@
       ## Metadata ##
     -Author: AZero13 <gfunni234@gmail.com>
     +Author: Greg Funni <gfunni234@gmail.com>
      
       ## Commit message ##
          win32: pthread_cond_wait should return a value


 compat/win32/pthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index e2b5c4f64c..000604cdf6 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;
 
 #define pthread_cond_t CONDITION_VARIABLE
 
-#define pthread_cond_init(a,b) InitializeConditionVariable((a))
+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
 #define pthread_cond_destroy(a) do {} while (0)
 #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
 #define pthread_cond_signal WakeConditionVariable

base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] win32: pthread_cond_wait should return a value
  2025-11-18 15:42 ` [PATCH v2] " AZero13 via GitGitGadget
@ 2025-11-18 18:17   ` Junio C Hamano
  2025-11-20 21:43   ` [PATCH v3] win32: pthread_cond_init " AZero13 via GitGitGadget
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-11-18 18:17 UTC (permalink / raw)
  To: AZero13 via GitGitGadget; +Cc: git, AZero13

"AZero13 via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Subject: Re: [PATCH v2] win32: pthread_cond_wait should return a value

Is this mistitled?  The patch text talks about cond_init(), not cond_wait(),
which is the theme for the other patch around SleepConditionVariableCS().

> 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>
> ---
> ...
> diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
> index e2b5c4f64c..000604cdf6 100644
> --- a/compat/win32/pthread.h
> +++ b/compat/win32/pthread.h
> @@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;
>  
>  #define pthread_cond_t CONDITION_VARIABLE
>  
> -#define pthread_cond_init(a,b) InitializeConditionVariable((a))
> +#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
>  #define pthread_cond_destroy(a) do {} while (0)
>  #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
>  #define pthread_cond_signal WakeConditionVariable
>
> base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3] win32: pthread_cond_init should return a value
  2025-11-18 15:42 ` [PATCH v2] " AZero13 via GitGitGadget
  2025-11-18 18:17   ` Junio C Hamano
@ 2025-11-20 21:43   ` AZero13 via GitGitGadget
  2025-11-21  1:46     ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: AZero13 via GitGitGadget @ 2025-11-20 21:43 UTC (permalink / raw)
  To: git; +Cc: AZero13, Greg Funni

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

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v3
Pull-Request: https://github.com/git/git/pull/2103

Range-diff vs v2:

 1:  a2d9ec97f1 ! 1:  19ce5aca70 win32: pthread_cond_wait should return a value
     @@ Metadata
      Author: Greg Funni <gfunni234@gmail.com>
      
       ## Commit message ##
     -    win32: pthread_cond_wait should return a value
     +    win32: pthread_cond_init should return a value
      
          This value is not checked, but it must return to match POSIX
      


 compat/win32/pthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index e2b5c4f64c..000604cdf6 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;
 
 #define pthread_cond_t CONDITION_VARIABLE
 
-#define pthread_cond_init(a,b) InitializeConditionVariable((a))
+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))
 #define pthread_cond_destroy(a) do {} while (0)
 #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
 #define pthread_cond_signal WakeConditionVariable

base-commit: 5e6e4854e086ba0025bc7dc11e6b475c92a2f556
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] win32: pthread_cond_init should return a value
  2025-11-20 21:43   ` [PATCH v3] win32: pthread_cond_init " AZero13 via GitGitGadget
@ 2025-11-21  1:46     ` Junio C Hamano
  2025-12-07  0:18       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2025-11-21  1:46 UTC (permalink / raw)
  To: AZero13 via GitGitGadget; +Cc: git, AZero13

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] win32: pthread_cond_init should return a value
  2025-11-21  1:46     ` Junio C Hamano
@ 2025-12-07  0:18       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-12-07  0:18 UTC (permalink / raw)
  To: git; +Cc: AZero13 via GitGitGadget, AZero13

Junio C Hamano <gitster@pobox.com> writes:

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-12-07  0:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18  0:59 [PATCH] win32: pthread_cond_wait should return a value AZero13 via GitGitGadget
2025-11-18 15:42 ` [PATCH v2] " AZero13 via GitGitGadget
2025-11-18 18:17   ` Junio C Hamano
2025-11-20 21:43   ` [PATCH v3] win32: pthread_cond_init " AZero13 via GitGitGadget
2025-11-21  1:46     ` Junio C Hamano
2025-12-07  0:18       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).