~ubuntu-branches/ubuntu/saucy/libpthread-workqueue/saucy

« back to all changes in this revision

Viewing changes to src/windows/platform.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Heily
  • Date: 2011-03-13 16:22:30 UTC
  • Revision ID: james.westby@ubuntu.com-20110313162230-yaiyoa7g3dk8xmww
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _PTWQ_WINDOWS_PLATFORM_H
 
2
#define _PTWQ_WINDOWS_PLATFORM_H 1
 
3
 
 
4
#define _WIN32_WINNT 0x0500
 
5
#define WIN32_LEAN_AND_MEAN
 
6
 
 
7
#include <windows.h>
 
8
 
 
9
/* Instead of __attribute__ ((constructor)), use DllMain() */
 
10
#define CONSTRUCTOR       /* */
 
11
 
 
12
#define VISIBLE __declspec(dllexport)
 
13
 
 
14
# define __func__ __FUNCTION__
 
15
 
 
16
#undef LIST_HEAD
 
17
#include "queue.h"
 
18
 
 
19
#define sleep(sec)      Sleep(1000*sec)
 
20
#define strdup(p)       _strdup(p)
 
21
#define random()        rand()
 
22
 
 
23
typedef HANDLE pthread_t;
 
24
 
 
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))
 
46
 
 
47
#endif  /* _PTWQ_WINDOWS_PLATFORM_H */