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

62 lines
1.0 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* pthread-win32.c
2004-08-29 07:07:03 +02:00
* partial pthread implementation for win32
*
2009-01-01 18:24:05 +01:00
* Copyright (c) 2004-2009, PostgreSQL Global Development Group
* IDENTIFICATION
2009-01-01 18:24:05 +01:00
* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.18 2009/01/01 17:24:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include <windows.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;
}