int
pthread_mutex_init(pthread_mutex_t *mp, void *attr)
{
- *mp = CreateMutex(0, 0, 0);
- if (*mp == NULL)
+ *mp = (CRITICAL_SECTION *)malloc(sizeof(CRITICAL_SECTION));
+ if (!*mp)
return 1;
+ InitializeCriticalSection(*mp);
return 0;
}
int
pthread_mutex_lock(pthread_mutex_t *mp)
{
- if (WaitForSingleObject(*mp, INFINITE) != WAIT_OBJECT_0)
+ if (!*mp)
return 1;
+ EnterCriticalSection(*mp);
return 0;
}
int
pthread_mutex_unlock(pthread_mutex_t *mp)
{
- if (!ReleaseMutex(*mp))
+ if (!*mp)
return 1;
+ LeaveCriticalSection(*mp);
return 0;
}
/*
- * $PostgreSQL:$
+ * $PostgreSQL$
*/
#ifndef __PTHREAD_H
#define __PTHREAD_H
typedef ULONG pthread_key_t;
-typedef HANDLE pthread_mutex_t;
+typedef CRITICAL_SECTION *pthread_mutex_t;
typedef int pthread_once_t;
DWORD pthread_self(void);