summaryrefslogtreecommitdiff
path: root/librabbitmq/win32/threads.c
blob: 0501408cfcfe0605a5f471afd0f7fd3c87294c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */
#include "threads.h"

DWORD
pthread_self(void)
{
  return GetCurrentThreadId();
}

int
pthread_mutex_init(pthread_mutex_t *mutex, void *attr)
{
  *mutex = malloc(sizeof(CRITICAL_SECTION));
  if (!*mutex)
    return 1;
  InitializeCriticalSection(*mutex);
  return 0;
}

int
pthread_mutex_lock(pthread_mutex_t *mutex)
{
  if (!*mutex)
    return 1;

  EnterCriticalSection(*mutex);
  return 0;
}

int
pthread_mutex_unlock(pthread_mutex_t *mutex)
{
  if (!*mutex)
    return 1;

  LeaveCriticalSection(*mutex);
  return 0;
}