Content-Length: 309245 | pFad | http://github.com/liweitianux/dragonflybsd/commit/d4cbe73475895089e9347b822e77c6a1802ad475

5F nvmm: Port to DragonFly #6: mutex/rwlock · liweitianux/dragonflybsd@d4cbe73 · GitHub
Skip to content

Commit d4cbe73

Browse files
committed
nvmm: Port to DragonFly DragonFlyBSD#6: mutex/rwlock
Add compat code to adapt NetBSD's mutex and rwlock to use DragonFly's lockmgr(9).
1 parent 97501a5 commit d4cbe73

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

sys/dev/virtual/nvmm/nvmm_compat.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343

4444
#include <sys/param.h>
4545
#include <sys/bitops.h>
46+
#include <sys/lock.h>
4647
#include <sys/systm.h>
48+
4749
#include <machine/cpufunc.h>
4850
#include <machine/specialreg.h>
4951

@@ -236,4 +238,28 @@
236238
#define x86_cpuid(eax, regs) do_cpuid(eax, regs)
237239
#define x86_cpuid2(eax, ecx, regs) cpuid_count(eax, ecx, regs)
238240

241+
/*
242+
* Mutex lock
243+
*/
244+
#define kmutex_t struct lock
245+
#define mutex_init(lock, type, ipl) lockinit(lock, "nvmmmtx", 0, 0)
246+
#define mutex_destroy(lock) lockuninit(lock)
247+
#define mutex_enter(lock) lockmgr(lock, LK_EXCLUSIVE)
248+
#define mutex_exit(lock) lockmgr(lock, LK_RELEASE)
249+
#define mutex_owned(lock) (lockstatus(lock, curthread) == LK_EXCLUSIVE)
250+
251+
/*
252+
* Reader/writer lock
253+
*/
254+
typedef enum krw_t {
255+
RW_READER = LK_SHARED,
256+
RW_WRITER = LK_EXCLUSIVE,
257+
} krw_t;
258+
#define krwlock_t struct lock
259+
#define rw_init(lock) lockinit(lock, "nvmmrw", 0, 0)
260+
#define rw_destroy(lock) lockuninit(lock)
261+
#define rw_enter(lock, op) lockmgr(lock, op)
262+
#define rw_exit(lock) lockmgr(lock, LK_RELEASE)
263+
#define rw_write_held(lock) (lockstatus(lock, curthread) == LK_EXCLUSIVE)
264+
239265
#endif /* _NVMM_COMPAT_H_ */

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/liweitianux/dragonflybsd/commit/d4cbe73475895089e9347b822e77c6a1802ad475

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy