diff options
Diffstat (limited to '')
-rw-r--r-- | src/interfaces/ecpg/include/ecpg-pthread-win32.h | 22 |
1 files changed, 8 insertions, 14 deletions
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)) |