PostgreSQL Source Code  git master
pthread-win32.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pthread_mutex_t
 

Macros

#define PTHREAD_MUTEX_INITIALIZER   { 0 }
 

Typedefs

typedef ULONG pthread_key_t
 
typedef struct pthread_mutex_t pthread_mutex_t
 
typedef int pthread_once_t
 

Functions

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

Macro Definition Documentation

◆ PTHREAD_MUTEX_INITIALIZER

#define PTHREAD_MUTEX_INITIALIZER   { 0 }

Definition at line 16 of file pthread-win32.h.

Typedef Documentation

◆ pthread_key_t

typedef ULONG pthread_key_t

Definition at line 7 of file pthread-win32.h.

◆ pthread_mutex_t

◆ pthread_once_t

typedef int pthread_once_t

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

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 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(), ecpg_get_connection(), ecpg_log(), ECPGconnect(), ECPGdebug(), ECPGdisconnect(), pgconn_bio_method(), 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(), ecpg_get_connection(), ecpg_log(), ECPGconnect(), ECPGdebug(), ECPGdisconnect(), pgconn_bio_method(), 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().