-
Notifications
You must be signed in to change notification settings - Fork 7
/
cm_lock.c
49 lines (41 loc) · 971 Bytes
/
cm_lock.c
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
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "config.h"
#include "ffs.h"
#include "atl.h"
#include "evpath.h"
#include "chr_time.h"
#include "cm_internal.h"
#undef NDEBUG
#include "assert.h"
extern void
IntCManager_lock(CManager cm, const char *file, int line)
{
CMtrace_out(cm, CMLowLevelVerbose, "CManager Lock at \"%s\" line %d\n",
file, line);
thr_mutex_lock(cm->exchange_lock);
cm->locked++;
if (cm->locked != 1) {
printf("CManager lock inconsistency, %d\n", cm->locked);
}
}
extern void
IntCManager_unlock(CManager cm, const char *file, int line)
{
CMtrace_out(cm, CMLowLevelVerbose, "CManager Unlock at \"%s\" line %d\n",
file, line);
cm->locked--;
if (cm->locked != 0) {
printf("CManager unlock inconsistency, %d\n", cm->locked);
}
thr_mutex_unlock(cm->exchange_lock);
}
extern int
CManager_locked(CManager cm)
{
return cm->locked;
}