]>
Commit | Line | Data |
---|---|---|
282113ba CV |
1 | /* bsd_mutex.h: BSD Mutex helper |
2 | ||
282113ba CV |
3 | This file is part of Cygwin. |
4 | ||
5 | This software is a copyrighted work licensed under the terms of the | |
6 | Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
7 | details. */ | |
8 | #ifndef _BSD_MUTEX_H | |
9 | #define _BSD_MUTEX_H | |
10 | ||
11 | #define MTX_DEF 0 | |
12 | ||
13 | #define MA_OWNED 1 | |
14 | #define MA_NOTOWNED 2 | |
15 | ||
16 | #define PZERO (0x20) | |
17 | #define PRIO_MASK (0x1f) | |
18 | #define PDROP 0x1000 | |
19 | #define PCATCH 0x2000 | |
20 | #define PLOCK 0x3000 | |
21 | ||
22 | struct mtx { | |
23 | HANDLE h; | |
24 | const char *name; | |
25 | DWORD owner; | |
dafef5e2 | 26 | unsigned long cnt; |
282113ba CV |
27 | }; |
28 | ||
29 | /* Some BSD kernel global mutex. */ | |
30 | extern struct mtx Giant; | |
31 | ||
32 | void mtx_init (mtx *, const char *, const void *, int); | |
4dbcfeb7 | 33 | void _mtx_lock (mtx *, DWORD, const char *, int); |
282113ba | 34 | #define mtx_lock(m) _mtx_lock((m), (td->ipcblk->winpid), __FILE__, __LINE__) |
dafef5e2 | 35 | int mtx_owned (mtx *, DWORD); |
4dbcfeb7 | 36 | void _mtx_assert(mtx *, int, DWORD, const char *, int); |
dafef5e2 | 37 | #define mtx_assert(m,w,p) _mtx_assert((m),(w),(p),__FILE__,__LINE__) |
282113ba CV |
38 | void _mtx_unlock (mtx *, const char *, int); |
39 | #define mtx_unlock(m) _mtx_unlock((m),__FILE__,__LINE__) | |
40 | ||
41 | void mtx_destroy (mtx *); | |
42 | ||
43 | void msleep_init (void); | |
c5ca43f3 CV |
44 | int _msleep (void *, struct mtx *, int, const char *, int, struct thread *); |
45 | #define msleep(i,m,p,w,t) _msleep((i),(m),(p),(w),(t),(td)) | |
46 | #define tsleep(i,p,w,t) _msleep((i),NULL,(p),(w),(t),(td)) | |
47 | int wakeup (void *); | |
282113ba CV |
48 | void wakeup_all (void); |
49 | ||
50 | #endif /* _BSD_MUTEX_H */ |