line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ifndef _WIN32 |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#else |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#endif |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#include |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "mutex.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
struct zmq_raw_mutex |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
#ifdef _WIN32 |
15
|
|
|
|
|
|
|
CRITICAL_SECTION m; |
16
|
|
|
|
|
|
|
#else |
17
|
|
|
|
|
|
|
pthread_mutex_t m; |
18
|
|
|
|
|
|
|
#endif |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
12
|
|
|
|
|
|
zmq_raw_mutex *zmq_raw_mutex_create() |
23
|
|
|
|
|
|
|
{ |
24
|
12
|
|
|
|
|
|
zmq_raw_mutex *m = malloc (sizeof (zmq_raw_mutex)); |
25
|
|
|
|
|
|
|
#ifdef _WIN32 |
26
|
|
|
|
|
|
|
InitializeCriticalSection (&m->m); |
27
|
|
|
|
|
|
|
#else |
28
|
12
|
|
|
|
|
|
int rc = pthread_mutex_init (&m->m, NULL); |
29
|
12
|
50
|
|
|
|
|
assert (rc == 0); |
30
|
|
|
|
|
|
|
#endif |
31
|
12
|
|
|
|
|
|
return m; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
12
|
|
|
|
|
|
void zmq_raw_mutex_destroy (zmq_raw_mutex *m) |
35
|
|
|
|
|
|
|
{ |
36
|
|
|
|
|
|
|
#ifdef _WIN32 |
37
|
|
|
|
|
|
|
DeleteCriticalSection (&m->m); |
38
|
|
|
|
|
|
|
#else |
39
|
12
|
|
|
|
|
|
int rc = pthread_mutex_destroy (&m->m); |
40
|
12
|
50
|
|
|
|
|
assert (rc == 0); |
41
|
|
|
|
|
|
|
#endif |
42
|
12
|
|
|
|
|
|
free (m); |
43
|
12
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
273
|
|
|
|
|
|
void zmq_raw_mutex_lock (zmq_raw_mutex *m) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
#ifdef _WIN32 |
48
|
|
|
|
|
|
|
EnterCriticalSection (&m->m); |
49
|
|
|
|
|
|
|
#else |
50
|
273
|
|
|
|
|
|
int rc = pthread_mutex_lock (&m->m); |
51
|
273
|
50
|
|
|
|
|
assert (rc == 0); |
52
|
|
|
|
|
|
|
#endif |
53
|
273
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
273
|
|
|
|
|
|
void zmq_raw_mutex_unlock (zmq_raw_mutex *m) |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
#ifdef _WIN32 |
58
|
|
|
|
|
|
|
LeaveCriticalSection (&m->m); |
59
|
|
|
|
|
|
|
#else |
60
|
273
|
|
|
|
|
|
int rc = pthread_mutex_unlock (&m->m); |
61
|
273
|
50
|
|
|
|
|
assert (rc == 0); |
62
|
|
|
|
|
|
|
#endif |
63
|
273
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|