FreeBSD/sys/kern/kern_event.c
/*
 * add a knote to a knlist
 */
add a knote to a knlist
add a knote to a knlist
void
knlist_add(struct knlist *knl, struct knote *kn, int islocked)
{
	KNL_ASSERT_LOCK(knl, islocked);
	KQ_NOTOWNED(kn->kn_kq);
	KASSERT((kn->kn_status & (KN_INFLUX|KN_DETACHED)) ==
	    (KN_INFLUX|KN_DETACHED), ("knote not KN_INFLUX and KN_DETACHED"));
	if (!islocked)
		knl->kl_lock(knl->kl_lockarg);
	SLIST_INSERT_HEAD(&knl->kl_list, kn, kn_selnext);
	if (!islocked)
		knl->kl_unlock(knl->kl_lockarg);
	KQ_LOCK(kn->kn_kq);
	kn->kn_knlist = knl;
	kn->kn_status &= ~KN_DETACHED;
	KQ_UNLOCK(kn->kn_kq);
}
void knlist_add ( struct knlist * knl , struct knote * kn , int islocked ) { KNL_ASSERT_LOCK ( knl , islocked ) ; KQ_NOTOWNED ( kn -> kn_kq ) ; KASSERT ( ( kn -> kn_status & ( KN_INFLUX | KN_DETACHED ) ) == ( KN_INFLUX | KN_DETACHED ) , ( " " ) ) ; if ( ! islocked ) knl -> kl_lock ( knl -> kl_lockarg ) ; SLIST_INSERT_HEAD ( & knl -> kl_list , kn , kn_selnext ) ; if ( ! islocked ) knl -> kl_unlock ( knl -> kl_lockarg ) ; KQ_LOCK ( kn -> kn_kq ) ; kn -> kn_knlist = knl ; kn -> kn_status &= ~ KN_DETACHED ; KQ_UNLOCK ( kn -> kn_kq ) ; }
add a knote to a knlist
add a knote to a knlist