Lines Matching defs:efd

110 	struct eventfd *efd;
116 efd = malloc(sizeof(*efd), M_EVENTFD, M_WAITOK | M_ZERO);
117 efd->efd_flags = flags;
118 efd->efd_count = initval;
119 mtx_init(&efd->efd_lock, "eventfd", NULL, MTX_DEF);
120 knlist_init_mtx(&efd->efd_sel.si_note, &efd->efd_lock);
125 finit(fp, fflags, DTYPE_EVENTFD, efd, &eventfdops);
133 struct eventfd *efd;
135 efd = fp->f_data;
136 seldrain(&efd->efd_sel);
137 knlist_destroy(&efd->efd_sel.si_note);
138 mtx_destroy(&efd->efd_lock);
139 free(efd, M_EVENTFD);
147 struct eventfd *efd;
155 efd = fp->f_data;
156 mtx_lock(&efd->efd_lock);
157 while (error == 0 && efd->efd_count == 0) {
159 mtx_unlock(&efd->efd_lock);
162 error = mtx_sleep(&efd->efd_count, &efd->efd_lock, PCATCH,
166 MPASS(efd->efd_count > 0);
167 if ((efd->efd_flags & EFD_SEMAPHORE) != 0) {
169 --efd->efd_count;
171 count = efd->efd_count;
172 efd->efd_count = 0;
174 KNOTE_LOCKED(&efd->efd_sel.si_note, 0);
175 selwakeup(&efd->efd_sel);
176 wakeup(&efd->efd_count);
177 mtx_unlock(&efd->efd_lock);
180 mtx_unlock(&efd->efd_lock);
189 struct eventfd *efd;
202 efd = fp->f_data;
203 mtx_lock(&efd->efd_lock);
205 if (UINT64_MAX - efd->efd_count <= count) {
207 mtx_unlock(&efd->efd_lock);
212 error = mtx_sleep(&efd->efd_count, &efd->efd_lock,
218 MPASS(UINT64_MAX - efd->efd_count > count);
219 efd->efd_count += count;
220 KNOTE_LOCKED(&efd->efd_sel.si_note, 0);
221 selwakeup(&efd->efd_sel);
222 wakeup(&efd->efd_count);
224 mtx_unlock(&efd->efd_lock);
233 struct eventfd *efd;
236 efd = fp->f_data;
238 mtx_lock(&efd->efd_lock);
239 if ((events & (POLLIN | POLLRDNORM)) != 0 && efd->efd_count > 0)
242 efd->efd_count)
245 selrecord(td, &efd->efd_sel);
246 mtx_unlock(&efd->efd_lock);
254 struct eventfd *efd = fp->f_data;
256 mtx_lock(&efd->efd_lock);
265 mtx_unlock(&efd->efd_lock);
269 kn->kn_hook = efd;
270 knlist_add(&efd->efd_sel.si_note, kn, 1);
271 mtx_unlock(&efd->efd_lock);
279 struct eventfd *efd = kn->kn_hook;
281 mtx_lock(&efd->efd_lock);
282 knlist_remove(&efd->efd_sel.si_note, kn, 1);
283 mtx_unlock(&efd->efd_lock);
289 struct eventfd *efd = kn->kn_hook;
292 mtx_assert(&efd->efd_lock, MA_OWNED);
293 kn->kn_data = (int64_t)efd->efd_count;
294 ret = efd->efd_count > 0;
302 struct eventfd *efd = kn->kn_hook;
305 mtx_assert(&efd->efd_lock, MA_OWNED);
306 kn->kn_data = (int64_t)(UINT64_MAX - 1 - efd->efd_count);
307 ret = UINT64_MAX - 1 > efd->efd_count;
336 struct eventfd *efd = fp->f_data;
339 mtx_lock(&efd->efd_lock);
340 kif->kf_un.kf_eventfd.kf_eventfd_value = efd->efd_count;
341 kif->kf_un.kf_eventfd.kf_eventfd_flags = efd->efd_flags;
342 kif->kf_un.kf_eventfd.kf_eventfd_addr = (uintptr_t)efd;
343 mtx_unlock(&efd->efd_lock);