postgresql/src/interfaces/libpq/pthread-win32.c

61 lines
994 B
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* pthread-win32.c
2004-08-29 07:07:03 +02:00
* partial pthread implementation for win32
*
2017-01-03 19:48:53 +01:00
* Copyright (c) 2004-2017, PostgreSQL Global Development Group
* IDENTIFICATION
2010-09-20 22:08:53 +02:00
* src/interfaces/libpq/pthread-win32.c
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "pthread-win32.h"
DWORD
2007-04-18 10:32:40 +02:00
pthread_self(void)
{
2005-08-28 20:49:01 +02:00
return GetCurrentThreadId();
}
2004-08-29 07:07:03 +02:00
void
pthread_setspecific(pthread_key_t key, void *val)
{
}
2004-08-29 07:07:03 +02:00
void *
pthread_getspecific(pthread_key_t key)
{
2004-08-29 07:07:03 +02:00
return NULL;
}
int
2004-08-29 07:07:03 +02:00
pthread_mutex_init(pthread_mutex_t *mp, void *attr)
{
*mp = (CRITICAL_SECTION *) malloc(sizeof(CRITICAL_SECTION));
if (!*mp)
return 1;
InitializeCriticalSection(*mp);
return 0;
}
int
2004-08-29 07:07:03 +02:00
pthread_mutex_lock(pthread_mutex_t *mp)
{
if (!*mp)
return 1;
EnterCriticalSection(*mp);
return 0;
}
int
2004-08-29 07:07:03 +02:00
pthread_mutex_unlock(pthread_mutex_t *mp)
{
if (!*mp)
return 1;
LeaveCriticalSection(*mp);
return 0;
}