Lines Matching refs:efd

683 	struct eventfd *efd;
696 efd = malloc(sizeof(*efd), M_EPOLL, M_WAITOK | M_ZERO);
697 efd->efd_flags = flags;
698 efd->efd_count = initval;
699 mtx_init(&efd->efd_lock, "eventfd", NULL, MTX_DEF);
701 knlist_init_mtx(&efd->efd_sel.si_note, &efd->efd_lock);
707 finit(fp, fflags, DTYPE_LINUXEFD, efd, &eventfdops);
736 struct eventfd *efd;
738 efd = fp->f_data;
739 if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
742 seldrain(&efd->efd_sel);
743 knlist_destroy(&efd->efd_sel.si_note);
746 mtx_destroy(&efd->efd_lock);
747 free(efd, M_EPOLL);
756 struct eventfd *efd;
760 efd = fp->f_data;
761 if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
768 mtx_lock(&efd->efd_lock);
770 if (efd->efd_count == 0) {
772 mtx_unlock(&efd->efd_lock);
775 error = mtx_sleep(&efd->efd_count, &efd->efd_lock, PCATCH, "lefdrd", 0);
780 if ((efd->efd_flags & LINUX_EFD_SEMAPHORE) != 0) {
782 --efd->efd_count;
784 count = efd->efd_count;
785 efd->efd_count = 0;
787 KNOTE_LOCKED(&efd->efd_sel.si_note, 0);
788 selwakeup(&efd->efd_sel);
789 wakeup(&efd->efd_count);
790 mtx_unlock(&efd->efd_lock);
793 mtx_unlock(&efd->efd_lock);
802 struct eventfd *efd;
806 efd = fp->f_data;
807 if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
819 mtx_lock(&efd->efd_lock);
821 if (UINT64_MAX - efd->efd_count <= count) {
823 mtx_unlock(&efd->efd_lock);
828 error = mtx_sleep(&efd->efd_count, &efd->efd_lock,
834 efd->efd_count += count;
835 KNOTE_LOCKED(&efd->efd_sel.si_note, 0);
836 selwakeup(&efd->efd_sel);
837 wakeup(&efd->efd_count);
839 mtx_unlock(&efd->efd_lock);
848 struct eventfd *efd;
851 efd = fp->f_data;
852 if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
855 mtx_lock(&efd->efd_lock);
856 if ((events & (POLLIN|POLLRDNORM)) && efd->efd_count > 0)
858 if ((events & (POLLOUT|POLLWRNORM)) && UINT64_MAX - 1 > efd->efd_count)
861 selrecord(td, &efd->efd_sel);
862 mtx_unlock(&efd->efd_lock);
871 struct eventfd *efd;
873 efd = fp->f_data;
874 if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
877 mtx_lock(&efd->efd_lock);
886 mtx_unlock(&efd->efd_lock);
890 kn->kn_hook = efd;
891 knlist_add(&efd->efd_sel.si_note, kn, 1);
892 mtx_unlock(&efd->efd_lock);
900 struct eventfd *efd = kn->kn_hook;
902 mtx_lock(&efd->efd_lock);
903 knlist_remove(&efd->efd_sel.si_note, kn, 1);
904 mtx_unlock(&efd->efd_lock);
911 struct eventfd *efd = kn->kn_hook;
914 mtx_assert(&efd->efd_lock, MA_OWNED);
915 ret = (efd->efd_count > 0);
924 struct eventfd *efd = kn->kn_hook;
927 mtx_assert(&efd->efd_lock, MA_OWNED);
928 ret = (UINT64_MAX - 1 > efd->efd_count);