PostgreSQL Source Code  git master
pthread-win32.c File Reference
#include "postgres_fe.h"
#include "pthread-win32.h"
Include dependency graph for pthread-win32.c:

Go to the source code of this file.

Functions

DWORD pthread_self (void)
 
void pthread_setspecific (pthread_key_t key, void *val)
 
void * pthread_getspecific (pthread_key_t key)
 
int pthread_mutex_init (pthread_mutex_t *mp, void *attr)
 
int pthread_mutex_lock (pthread_mutex_t *mp)
 
int pthread_mutex_unlock (pthread_mutex_t *mp)
 

Function Documentation

◆ pthread_getspecific()

void* pthread_getspecific ( pthread_key_t  key)

Definition at line 29 of file pthread-win32.c.

30 {
31  return NULL;
32 }

Referenced by ecpg_finish(), ecpg_get_connection(), ecpg_get_connection_nr(), ECPGget_sqlca(), get_auto_allocs(), and get_descriptors().

◆ pthread_mutex_init()

int pthread_mutex_init ( pthread_mutex_t mp,
void *  attr 
)

Definition at line 35 of file pthread-win32.c.

36 {
37  mp->initstate = 0;
38  return 0;
39 }

References pthread_mutex_t::initstate.

Referenced by pgtls_init(), and pthread_barrier_init().

◆ pthread_mutex_lock()

int pthread_mutex_lock ( pthread_mutex_t mp)

Definition at line 42 of file pthread-win32.c.

43 {
44  /* Initialize the csection if not already done */
45  if (mp->initstate != 1)
46  {
47  LONG istate;
48 
49  while ((istate = InterlockedExchange(&mp->initstate, 2)) == 2)
50  Sleep(0); /* wait, another thread is doing this */
51  if (istate != 1)
52  InitializeCriticalSection(&mp->csection);
53  InterlockedExchange(&mp->initstate, 1);
54  }
55  EnterCriticalSection(&mp->csection);
56  return 0;
57 }
CRITICAL_SECTION csection
Definition: pthread-win32.h:13

References pthread_mutex_t::csection, and pthread_mutex_t::initstate.

Referenced by default_threadlock(), destroy_ssl_system(), ecpg_get_connection(), ecpg_log(), ECPGconnect(), ECPGdebug(), ECPGdisconnect(), my_BIO_s_socket(), pgtls_init(), and pthread_barrier_wait().

◆ pthread_mutex_unlock()

int pthread_mutex_unlock ( pthread_mutex_t mp)

Definition at line 60 of file pthread-win32.c.

61 {
62  if (mp->initstate != 1)
63  return EINVAL;
64  LeaveCriticalSection(&mp->csection);
65  return 0;
66 }

References pthread_mutex_t::csection, and pthread_mutex_t::initstate.

Referenced by default_threadlock(), destroy_ssl_system(), ecpg_get_connection(), ecpg_log(), ECPGconnect(), ECPGdebug(), ECPGdisconnect(), my_BIO_s_socket(), pgtls_init(), and pthread_barrier_wait().

◆ pthread_self()

DWORD pthread_self ( void  )

Definition at line 18 of file pthread-win32.c.

19 {
20  return GetCurrentThreadId();
21 }

◆ pthread_setspecific()

void pthread_setspecific ( pthread_key_t  key,
void *  val 
)

Definition at line 24 of file pthread-win32.c.

25 {
26 }

Referenced by ecpg_finish(), ECPGconnect(), ECPGget_sqlca(), ECPGsetconn(), set_auto_allocs(), and set_descriptors().