OSDN Git Service

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