Lines Matching refs:lp

353 _audit_rw_init(struct rwlock *lp, const char *lckname)
355 _audit_rw_init(struct rwlock *lp, __unused const char *lckname)
358 lp->rw_lock = lck_rw_alloc_init(audit_lck_grp, LCK_ATTR_NULL);
359 KASSERT(lp->rw_lock != NULL,
362 strlcpy(lp->rw_name, lckname, AU_MAX_LCK_NAME);
367 _audit_rw_destroy(struct rwlock *lp)
370 if (lp->rw_lock) {
371 lck_rw_free(lp->rw_lock, audit_lck_grp);
372 lp->rw_lock = NULL;
402 _audit_rlck_init(struct rlck *lp, const char *lckname)
404 _audit_rlck_init(struct rlck *lp, __unused const char *lckname)
408 lp->rl_mtx = lck_mtx_alloc_init(audit_lck_grp, LCK_ATTR_NULL);
409 KASSERT(lp->rl_mtx != NULL,
412 strlcpy(lp->rl_name, lckname, AU_MAX_LCK_NAME);
414 lp->rl_thread = 0;
415 lp->rl_recurse = 0;
422 _audit_rlck_lock(struct rlck *lp)
425 if (lp->rl_thread == current_thread()) {
426 OSAddAtomic(1, &lp->rl_recurse);
427 KASSERT(lp->rl_recurse < 10000,
430 lck_mtx_lock(lp->rl_mtx);
431 lp->rl_thread = current_thread();
432 lp->rl_recurse = 1;
440 _audit_rlck_unlock(struct rlck *lp)
442 KASSERT(lp->rl_thread == current_thread(),
446 if (OSAddAtomic(-1, &lp->rl_recurse) == 1) {
447 lp->rl_thread = 0;
448 lck_mtx_unlock(lp->rl_mtx);
453 _audit_rlck_destroy(struct rlck *lp)
456 if (lp->rl_mtx) {
457 lck_mtx_free(lp->rl_mtx, audit_lck_grp);
458 lp->rl_mtx = NULL;
466 _audit_rlck_assert(struct rlck *lp, u_int assert)
470 if (assert == LCK_MTX_ASSERT_OWNED && lp->rl_thread == cthd)
472 lp, cthd);
473 if (assert == LCK_MTX_ASSERT_NOTOWNED && lp->rl_thread != 0)
475 lp, cthd);
483 _audit_slck_init(struct slck *lp, const char *lckname)
485 _audit_slck_init(struct slck *lp, __unused const char *lckname)
489 lp->sl_mtx = lck_mtx_alloc_init(audit_lck_grp, LCK_ATTR_NULL);
490 KASSERT(lp->sl_mtx != NULL,
493 strlcpy(lp->sl_name, lckname, AU_MAX_LCK_NAME);
495 lp->sl_locked = 0;
496 lp->sl_waiting = 0;
504 _audit_slck_lock(struct slck *lp, int intr)
508 lck_mtx_lock(lp->sl_mtx);
509 while (lp->sl_locked && res == THREAD_AWAKENED) {
510 lp->sl_waiting = 1;
511 res = lck_mtx_sleep(lp->sl_mtx, LCK_SLEEP_DEFAULT,
512 (event_t) lp, (intr) ? THREAD_INTERRUPTIBLE : THREAD_UNINT);
515 lp->sl_locked = 1;
516 lck_mtx_unlock(lp->sl_mtx);
525 _audit_slck_unlock(struct slck *lp)
528 lck_mtx_lock(lp->sl_mtx);
529 lp->sl_locked = 0;
530 if (lp->sl_waiting) {
531 lp->sl_waiting = 0;
534 wakeup((event_t) lp);
536 lck_mtx_unlock(lp->sl_mtx);
543 _audit_slck_trylock(struct slck *lp)
547 lck_mtx_lock(lp->sl_mtx);
548 result = !lp->sl_locked;
550 lp->sl_locked = 1;
551 lck_mtx_unlock(lp->sl_mtx);
560 _audit_slck_assert(struct slck *lp, u_int assert)
563 if (assert == LCK_MTX_ASSERT_OWNED && lp->sl_locked == 0)
564 panic("sleep lock (%p) not held.", lp);
565 if (assert == LCK_MTX_ASSERT_NOTOWNED && lp->sl_locked == 1)
566 panic("sleep lock (%p) held.", lp);
570 _audit_slck_destroy(struct slck *lp)
573 if (lp->sl_mtx) {
574 lck_mtx_free(lp->sl_mtx, audit_lck_grp);
575 lp->sl_mtx = NULL;