blob: 58c79a381426449927ac937c231b713275e1dcd5 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include "conf.h"
#include "thread.h"
#include <unistd.h>
#ifdef THREADSAFECLIENT
#include <pthread.h>
#endif
#ifdef THREADSAFECLIENT
short
thread_id()
{
short i;
i = ((unsigned int)pthread_self() & 0xff) | (getpid() << 8);
return i;
}
int
_nast_mutex_new(_nast_mutex_t *lock)
{
return pthread_mutex_init(lock, NULL);
}
void
_nast_mutex_delete(_nast_mutex_t *lock)
{
(void)pthread_mutex_destroy(lock);
}
int
_nast_mutex_lock(_nast_mutex_t *lock)
{
return pthread_mutex_lock(lock);
}
int
_nast_mutex_unlock(_nast_mutex_t *lock)
{
return pthread_mutex_unlock(lock);
}
#else /* THREADSAFECLIENT */
short
thread_id()
{
return getpid();
}
int
_nast_mutex_new(_nast_mutex_t *lock)
{
return 0;
}
void
_nast_mutex_delete(_nast_mutex_t *lock)
{
return;
}
int
_nast_mutex_lock(_nast_mutex_t *lock)
{
return 0;
}
int
_nast_mutex_unlock(_nast_mutex_t *lock)
{
return 0;
}
#endif /* THREADSAFECLIENT */
|