{"thread":{"id":"64502","subject":"[PATCH] win32: pthread_cond_wait should return a value","startedAt":"2025-11-18T01:00:01Z","lastAt":"2025-12-07T00:18:34Z","messageCount":6,"participants":["AZero13 via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"530868","messageId":"pull.2103.git.git.1763427599300.gitgitgadget@gmail.com","threadId":"64502","inReplyTo":null,"subject":"[PATCH] win32: pthread_cond_wait should return a value","fromName":"AZero13 via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-18T00:59:59Z","receivedAt":"2025-11-18T01:00:01Z","isPatch":true,"sender":{"key":"name:AZero13","avatar":null},"body":"From: AZero13 <gfunni234@gmail.com>\n\nThis value is not checked, but it must return to match POSIX\n\nSigned-off-by: Greg Funni <gfunni234@gmail.com>\n---\n    win32: pthread_cond_wait should return a value\n    \n    This value is not checked, but it must return to match POSIX\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v1\nPull-Request: https://github.com/git/git/pull/2103\n\n compat/win32/pthread.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/win32/pthread.h b/compat/win32/pthread.h\nindex e2b5c4f64c..000604cdf6 100644\n--- a/compat/win32/pthread.h\n+++ b/compat/win32/pthread.h\n@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;\n \n #define pthread_cond_t CONDITION_VARIABLE\n \n-#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n #define pthread_cond_destroy(a) do {} while (0)\n #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))\n #define pthread_cond_signal WakeConditionVariable\n\nbase-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed\n-- \ngitgitgadget\n"},{"id":"530905","messageId":"pull.2103.v2.git.git.1763480546981.gitgitgadget@gmail.com","threadId":"64502","inReplyTo":"pull.2103.git.git.1763427599300.gitgitgadget@gmail.com","subject":"[PATCH v2] win32: pthread_cond_wait should return a value","fromName":"AZero13 via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-18T15:42:26Z","receivedAt":"2025-11-18T15:42:29Z","isPatch":true,"sender":{"key":"name:AZero13","avatar":null},"body":"From: Greg Funni <gfunni234@gmail.com>\n\nThis value is not checked, but it must return to match POSIX\n\nSigned-off-by: Greg Funni <gfunni234@gmail.com>\n---\n    win32: pthread_cond_wait should return a value\n    \n    This value is not checked, but it must return to match POSIX\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v2\nPull-Request: https://github.com/git/git/pull/2103\n\nRange-diff vs v1:\n\n 1:  643a9b7eae ! 1:  a2d9ec97f1 win32: pthread_cond_wait should return a value\n     @@\n       ## Metadata ##\n     -Author: AZero13 <gfunni234@gmail.com>\n     +Author: Greg Funni <gfunni234@gmail.com>\n      \n       ## Commit message ##\n          win32: pthread_cond_wait should return a value\n\n\n compat/win32/pthread.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/win32/pthread.h b/compat/win32/pthread.h\nindex e2b5c4f64c..000604cdf6 100644\n--- a/compat/win32/pthread.h\n+++ b/compat/win32/pthread.h\n@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;\n \n #define pthread_cond_t CONDITION_VARIABLE\n \n-#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n #define pthread_cond_destroy(a) do {} while (0)\n #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))\n #define pthread_cond_signal WakeConditionVariable\n\nbase-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed\n-- \ngitgitgadget\n"},{"id":"530914","messageId":"xmqqms4jdx3c.fsf@gitster.g","threadId":"64502","inReplyTo":"pull.2103.v2.git.git.1763480546981.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] win32: pthread_cond_wait should return a value","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-18T18:17:27Z","receivedAt":"2025-11-18T18:17:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"AZero13 via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Subject: Re: [PATCH v2] win32: pthread_cond_wait should return a value\n\nIs this mistitled?  The patch text talks about cond_init(), not cond_wait(),\nwhich is the theme for the other patch around SleepConditionVariableCS().\n\n> From: Greg Funni <gfunni234@gmail.com>\n>\n> This value is not checked, but it must return to match POSIX\n>\n> Signed-off-by: Greg Funni <gfunni234@gmail.com>\n> ---\n> ...\n> diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h\n> index e2b5c4f64c..000604cdf6 100644\n> --- a/compat/win32/pthread.h\n> +++ b/compat/win32/pthread.h\n> @@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;\n>  \n>  #define pthread_cond_t CONDITION_VARIABLE\n>  \n> -#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n> +#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n>  #define pthread_cond_destroy(a) do {} while (0)\n>  #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))\n>  #define pthread_cond_signal WakeConditionVariable\n>\n> base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed\n"},{"id":"531083","messageId":"pull.2103.v3.git.git.1763675016637.gitgitgadget@gmail.com","threadId":"64502","inReplyTo":"pull.2103.v2.git.git.1763480546981.gitgitgadget@gmail.com","subject":"[PATCH v3] win32: pthread_cond_init should return a value","fromName":"AZero13 via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-20T21:43:36Z","receivedAt":"2025-11-20T21:43:40Z","isPatch":true,"sender":{"key":"name:AZero13","avatar":null},"body":"From: Greg Funni <gfunni234@gmail.com>\n\nThis value is not checked, but it must return to match POSIX\n\nSigned-off-by: Greg Funni <gfunni234@gmail.com>\n---\n    win32: pthread_cond_init should return a value\n    \n    This value is not checked, but it must return to match POSIX\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2103%2FAZero13%2Fpthread-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2103/AZero13/pthread-v3\nPull-Request: https://github.com/git/git/pull/2103\n\nRange-diff vs v2:\n\n 1:  a2d9ec97f1 ! 1:  19ce5aca70 win32: pthread_cond_wait should return a value\n     @@ Metadata\n      Author: Greg Funni <gfunni234@gmail.com>\n      \n       ## Commit message ##\n     -    win32: pthread_cond_wait should return a value\n     +    win32: pthread_cond_init should return a value\n      \n          This value is not checked, but it must return to match POSIX\n      \n\n\n compat/win32/pthread.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/win32/pthread.h b/compat/win32/pthread.h\nindex e2b5c4f64c..000604cdf6 100644\n--- a/compat/win32/pthread.h\n+++ b/compat/win32/pthread.h\n@@ -34,7 +34,7 @@ typedef int pthread_mutexattr_t;\n \n #define pthread_cond_t CONDITION_VARIABLE\n \n-#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n+#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n #define pthread_cond_destroy(a) do {} while (0)\n #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))\n #define pthread_cond_signal WakeConditionVariable\n\nbase-commit: 5e6e4854e086ba0025bc7dc11e6b475c92a2f556\n-- \ngitgitgadget\n"},{"id":"531099","messageId":"xmqqecps5f8u.fsf@gitster.g","threadId":"64502","inReplyTo":"pull.2103.v3.git.git.1763675016637.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] win32: pthread_cond_init should return a value","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-21T01:46:57Z","receivedAt":"2025-11-21T01:46:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"AZero13 via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Greg Funni <gfunni234@gmail.com>\n>\n> This value is not checked, but it must return to match POSIX\n>\n> Signed-off-by: Greg Funni <gfunni234@gmail.com>\n> ---\n>     win32: pthread_cond_init should return a value\n>     \n>     This value is not checked, but it must return to match POSIX\n> ...\n> -#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n> +#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n\nThis is tricky and I like it.\n\nBecause InitializeConditionVariable() returns void, and return_0()\nis defined as such:\n\n    static inline int return_0(int i) { return 0; }\n\nyou cannot directly pass InitializeConditionVariable() to it, so you\nuse a comma operator and pass 0 to return_0().  Because the type of\nthe comma operator with mixed operands is the type of the rightmost\noperand, the type of \"InitializeConditionVariable((a)), 0\" is type\nof \"0\", so return_0() would happily take it as an int, and returns\n0.\n\nThis should work correctly, but it still is tricky and yucky.\n\nYou may not have to use return_0(), but OK.\n\nWill queue.  Thanks.\n"},{"id":"531784","messageId":"xmqqwm2znnzc.fsf@gitster.g","threadId":"64502","inReplyTo":"xmqqecps5f8u.fsf@gitster.g","subject":"Re: [PATCH v3] win32: pthread_cond_init should return a value","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-07T00:18:31Z","receivedAt":"2025-12-07T00:18:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"AZero13 via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n>> From: Greg Funni <gfunni234@gmail.com>\n>>\n>> This value is not checked, but it must return to match POSIX\n>>\n>> Signed-off-by: Greg Funni <gfunni234@gmail.com>\n>> ---\n>>     win32: pthread_cond_init should return a value\n>>     \n>>     This value is not checked, but it must return to match POSIX\n>> ...\n>> -#define pthread_cond_init(a,b) InitializeConditionVariable((a))\n>> +#define pthread_cond_init(a,b) return_0((InitializeConditionVariable((a)), 0))\n>\n> This is tricky and I like it.\n>\n> Because InitializeConditionVariable() returns void, and return_0()\n> is defined as such:\n>\n>     static inline int return_0(int i) { return 0; }\n>\n> you cannot directly pass InitializeConditionVariable() to it, so you\n> use a comma operator and pass 0 to return_0().  Because the type of\n> the comma operator with mixed operands is the type of the rightmost\n> operand, the type of \"InitializeConditionVariable((a)), 0\" is type\n> of \"0\", so return_0() would happily take it as an int, and returns\n> 0.\n>\n> This should work correctly, but it still is tricky and yucky.\n>\n> You may not have to use return_0(), but OK.\n>\n> Will queue.  Thanks.\n\nAs I do not do Windows, I was hoping somebody more clueful than\nmyself on the platform would give an Ack to this patch, but we saw\nnothing.  I'll mark the topic for 'next'.  I do not anticipate\nbreakage but if there were something fishy, hopefully we will hear\nquickly enough.\n"}]}