1
#ifndef _PTWQ_WINDOWS_PLATFORM_H
2
#define _PTWQ_WINDOWS_PLATFORM_H 1
4
#define _WIN32_WINNT 0x0500
5
#define WIN32_LEAN_AND_MEAN
9
/* Instead of __attribute__ ((constructor)), use DllMain() */
10
#define CONSTRUCTOR /* */
12
#define VISIBLE __declspec(dllexport)
14
# define __func__ __FUNCTION__
19
#define sleep(sec) Sleep(1000*sec)
20
#define strdup(p) _strdup(p)
21
#define random() rand()
23
typedef HANDLE pthread_t;
25
/* Emulation of pthreads mutex functionality */
26
/* (copied from libkqueue) */
27
#define PTHREAD_PROCESS_SHARED 1
28
#define PTHREAD_PROCESS_PRIVATE 2
29
typedef CRITICAL_SECTION pthread_mutex_t;
30
typedef CRITICAL_SECTION pthread_spinlock_t;
31
typedef CRITICAL_SECTION pthread_rwlock_t;
32
#define _cs_init(x) InitializeCriticalSection((x))
33
#define _cs_lock(x) EnterCriticalSection ((x))
34
#define _cs_unlock(x) LeaveCriticalSection ((x))
35
#define pthread_mutex_lock _cs_lock
36
#define pthread_mutex_unlock _cs_unlock
37
#define pthread_mutex_init(x,y) _cs_init((x))
38
#define pthread_spin_lock _cs_lock
39
#define pthread_spin_unlock _cs_unlock
40
#define pthread_spin_init(x,y) _cs_init((x))
41
#define pthread_mutex_init(x,y) _cs_init((x))
42
#define pthread_rwlock_rdlock _cs_lock
43
#define pthread_rwlock_wrlock _cs_lock
44
#define pthread_rwlock_unlock _cs_unlock
45
#define pthread_rwlock_init(x,y) _cs_init((x))
47
#endif /* _PTWQ_WINDOWS_PLATFORM_H */