1 #include <netgraph7/ng_message.h>
3 #include <sys/malloc.h>
4 #include <sys/linker.h>
5 #include <sys/thread2.h>
10 /* Temporary lock stuff. */
12 /* End Temporary lock stuff. */
15 linker_api_available(void)
17 /* linker_* API won't work without a process context */
21 * nlookup_init() relies on namei_oc to be initialized,
22 * but it's not when the netgraph module is loaded during boot.
35 lockstatus_owned(struct lock *lkp, struct thread *td)
39 if (lkp->lk_exclusivecount != 0) {
40 if (td == NULL || lkp->lk_lockholder == td)
41 lock_type = LK_EXCLUSIVE;
43 lock_type = LK_EXCLOTHER;
44 } else if (lkp->lk_sharecount != 0) {
45 lock_type = LK_SHARED;
51 * Atomically drop a lockmgr lock and go to sleep. The lock is reacquired
52 * before returning from this function. Passes on the value returned by
56 lock_sleep(void *ident, int flags, const char *wmesg, int timo,
61 mode = lockstatus_owned(lk, curthread);
62 KKASSERT((mode == LK_EXCLUSIVE) || (mode == LK_SHARED));
65 tsleep_interlock(ident, flags);
66 lockmgr(lk, LK_RELEASE);
67 err = tsleep(ident, flags, wmesg, timo);