[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Re: [PATCH] win32: remove return_0 inline function
From:       Đoàn Trần Công Danh  <congdanhqx () gmail ! com>
Date:       2022-12-31 2:51:50
Message-ID: Y6+jxkZjBMurBiw5 () danh ! dev
[Download RAW message or body]

On 2022-12-31 02:20:21+0000, Rose via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Seija Kijin <doremylover123@gmail.com>
> 
> The macro works on its own without the helper function

NACK

>  #define pthread_mutex_t CRITICAL_SECTION
>  
> -static inline int return_0(int i) {
> -	return 0;
> +static inline int return_i(int i) {
> +	return i;
>  }
> -#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0))
> +#define pthread_mutex_init(a,b) return_i((InitializeCriticalSection((a)), 0))

This change does nothing and harmless in its own.

>  #define pthread_mutex_destroy(a) DeleteCriticalSection((a))
>  #define pthread_mutex_lock EnterCriticalSection
>  #define pthread_mutex_unlock LeaveCriticalSection
> @@ -36,7 +36,7 @@ typedef int pthread_mutexattr_t;
>  
>  #define pthread_cond_init(a,b) InitializeConditionVariable((a))
>  #define pthread_cond_destroy(a) do {} while (0)
> -#define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE))
> +#define pthread_cond_wait(a,b) SleepConditionVariableCS((a), (b), INFINITE)

But this is not,
pthread_cond_wait return 0 on success, otherwise error number.
SleepConditionVariableCS return non-zero on success, 0 on failure.

IOW, this change is broken on Windows.

-- 
Danh
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic