Lines Matching defs:tfd

91 timerfd_fire_count(const struct timerfd * const tfd)
93 return (unsigned int)tfd->tfd_itimer.it_overruns;
97 timerfd_is_readable(const struct timerfd * const tfd)
99 return tfd->tfd_itimer.it_overruns != 0 || tfd->tfd_cancelled;
112 struct timerfd * const tfd =
116 timerfd_wake(tfd);
130 struct timerfd * const tfd =
136 if (tfd->tfd_cancel_on_set) {
137 tfd->tfd_cancelled = true;
138 timerfd_wake(tfd);
159 struct timerfd * const tfd = kmem_zalloc(sizeof(*tfd), KM_SLEEP);
163 cv_init(&tfd->tfd_read_wait, "tfdread");
164 selinit(&tfd->tfd_read_sel);
165 getnanotime(&tfd->tfd_btime);
170 itimer_init(&tfd->tfd_itimer,
176 return tfd;
185 timerfd_destroy(struct timerfd * const tfd)
188 KASSERT(tfd->tfd_nwaiters == 0);
191 itimer_poison(&tfd->tfd_itimer);
192 itimer_fini(&tfd->tfd_itimer); /* drops itimer lock */
194 cv_destroy(&tfd->tfd_read_wait);
196 seldestroy(&tfd->tfd_read_sel);
198 kmem_free(tfd, sizeof(*tfd));
208 timerfd_wait(struct timerfd * const tfd, int const fflag)
220 if (tfd->tfd_restarting) {
224 tfd->tfd_nwaiters++;
225 KASSERT(tfd->tfd_nwaiters > 0);
226 error = cv_wait_sig(&tfd->tfd_read_wait, &itimer_mutex);
227 tfd->tfd_nwaiters--;
228 KASSERT(tfd->tfd_nwaiters >= 0);
234 if (tfd->tfd_restarting) {
249 timerfd_wake(struct timerfd * const tfd)
252 if (tfd->tfd_nwaiters) {
253 cv_broadcast(&tfd->tfd_read_wait);
255 selnotify(&tfd->tfd_read_sel, POLLIN | POLLRDNORM, NOTE_SUBMIT);
266 struct timerfd * const tfd = fp->f_timerfd;
267 struct itimer * const it = &tfd->tfd_itimer;
278 while (!timerfd_is_readable(tfd)) {
279 if ((error = timerfd_wait(tfd, fflag)) != 0) {
285 if (tfd->tfd_cancelled) {
290 return_value = timerfd_fire_count(tfd);
293 getnanotime(&tfd->tfd_atime);
305 struct timerfd * const tfd = fp->f_timerfd;
314 *(int *)data = timerfd_is_readable(tfd) ? sizeof(uint64_t) : 0;
324 tfd->tfd_itimer.it_overruns = (int)*new_ticksp;
339 struct timerfd * const tfd = fp->f_timerfd;
344 if (timerfd_is_readable(tfd)) {
347 selrecord(curlwp, &tfd->tfd_read_sel);
358 struct timerfd * const tfd = fp->f_timerfd;
363 st->st_size = (off_t)timerfd_fire_count(tfd);
364 st->st_atimespec = tfd->tfd_atime;
365 st->st_mtimespec = tfd->tfd_mtime;
371 st->st_birthtimespec = tfd->tfd_btime;
382 struct timerfd * const tfd = fp->f_timerfd;
385 timerfd_destroy(tfd);
393 struct timerfd * const tfd = ((file_t *)kn->kn_obj)->f_timerfd;
396 KASSERT(kn->kn_hook == tfd);
397 selremove_knote(&tfd->tfd_read_sel, kn);
404 struct timerfd * const tfd = ((file_t *)kn->kn_obj)->f_timerfd;
413 kn->kn_data = (int64_t)timerfd_fire_count(tfd);
432 struct timerfd * const tfd = ((file_t *)kn->kn_obj)->f_timerfd;
437 sel = &tfd->tfd_read_sel;
445 kn->kn_hook = tfd;
457 struct timerfd * const tfd = fp->f_timerfd;
466 if (tfd->tfd_nwaiters != 0) {
467 tfd->tfd_restarting = true;
468 cv_broadcast(&tfd->tfd_read_wait);
560 struct timerfd * const tfd = fp->f_timerfd;
562 itimer_gettime(&tfd->tfd_itimer, curr_value);
617 struct timerfd * const tfd = fp->f_timerfd;
618 struct itimer * const it = &tfd->tfd_itimer;
657 tfd->tfd_cancelled = false;
658 tfd->tfd_cancel_on_set = !!(flags & TFD_TIMER_CANCEL_ON_SET);
661 getnanotime(&tfd->tfd_mtime);