From e75d99818dd3940be997520e64db8c9e3b207e39 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 21 May 2024 07:05:26 +0200 Subject: Merging upstream version 15.7. Signed-off-by: Daniel Baumann --- src/interfaces/ecpg/include/ecpg-pthread-win32.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/interfaces/ecpg/include/ecpg-pthread-win32.h') diff --git a/src/interfaces/ecpg/include/ecpg-pthread-win32.h b/src/interfaces/ecpg/include/ecpg-pthread-win32.h index 33c897b..2782e49 100644 --- a/src/interfaces/ecpg/include/ecpg-pthread-win32.h +++ b/src/interfaces/ecpg/include/ecpg-pthread-win32.h @@ -14,28 +14,22 @@ typedef struct pthread_mutex_t { - HANDLE handle; - LONG initlock; + /* initstate = 0: not initialized; 1: init done; 2: init in progress */ + LONG initstate; + CRITICAL_SECTION csection; } pthread_mutex_t; typedef DWORD pthread_key_t; typedef bool pthread_once_t; -#define PTHREAD_MUTEX_INITIALIZER { NULL, 0 } +#define PTHREAD_MUTEX_INITIALIZER { 0 } #define PTHREAD_ONCE_INIT false -void win32_pthread_mutex(volatile pthread_mutex_t *mutex); -void win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void)); +int pthread_mutex_init(pthread_mutex_t *, void *attr); +int pthread_mutex_lock(pthread_mutex_t *); +int pthread_mutex_unlock(pthread_mutex_t *); -#define pthread_mutex_lock(mutex) \ - do { \ - if ((mutex)->handle == NULL) \ - win32_pthread_mutex((mutex)); \ - WaitForSingleObject((mutex)->handle, INFINITE); \ - } while(0) - -#define pthread_mutex_unlock(mutex) \ - ReleaseMutex((mutex)->handle) +void win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void)); #define pthread_getspecific(key) \ TlsGetValue((key)) -- cgit v1.2.3