]> granicus.if.org Git - postgresql/blob - src/interfaces/libpq/pthread-win32.c
libpq: use pgsocket for socket values, for portability
[postgresql] / src / interfaces / libpq / pthread-win32.c
1 /*-------------------------------------------------------------------------
2 *
3 * pthread-win32.c
4 *        partial pthread implementation for win32
5 *
6 * Copyright (c) 2004-2014, PostgreSQL Global Development Group
7 * IDENTIFICATION
8 *       src/interfaces/libpq/pthread-win32.c
9 *
10 *-------------------------------------------------------------------------
11 */
12
13 #include "postgres_fe.h"
14
15 #include <windows.h>
16 #include "pthread-win32.h"
17
18 DWORD
19 pthread_self(void)
20 {
21         return GetCurrentThreadId();
22 }
23
24 void
25 pthread_setspecific(pthread_key_t key, void *val)
26 {
27 }
28
29 void *
30 pthread_getspecific(pthread_key_t key)
31 {
32         return NULL;
33 }
34
35 int
36 pthread_mutex_init(pthread_mutex_t *mp, void *attr)
37 {
38         *mp = (CRITICAL_SECTION *) malloc(sizeof(CRITICAL_SECTION));
39         if (!*mp)
40                 return 1;
41         InitializeCriticalSection(*mp);
42         return 0;
43 }
44
45 int
46 pthread_mutex_lock(pthread_mutex_t *mp)
47 {
48         if (!*mp)
49                 return 1;
50         EnterCriticalSection(*mp);
51         return 0;
52 }
53
54 int
55 pthread_mutex_unlock(pthread_mutex_t *mp)
56 {
57         if (!*mp)
58                 return 1;
59         LeaveCriticalSection(*mp);
60         return 0;
61 }