| 108 | }; |
| 109 | |
| 110 | int |
| 111 | eventfd_create_file(struct thread *td, struct file *fp, uint32_t initval, |
| 112 | int flags) |
| 113 | { |
| 114 | struct eventfd *efd; |
| 115 | int fflags; |
| 116 | |
| 117 | AUDIT_ARG_FFLAGS(flags); |
| 118 | AUDIT_ARG_VALUE(initval); |
| 119 | |
| 120 | efd = malloc(sizeof(*efd), M_EVENTFD, M_WAITOK | M_ZERO); |
| 121 | efd->efd_flags = flags; |
| 122 | efd->efd_count = initval; |
| 123 | mtx_init(&efd->efd_lock, "eventfd", NULL, MTX_DEF); |
| 124 | knlist_init_mtx(&efd->efd_sel.si_note, &efd->efd_lock); |
| 125 | |
| 126 | fflags = FREAD | FWRITE; |
| 127 | if ((flags & EFD_NONBLOCK) != 0) |
| 128 | fflags |= FNONBLOCK; |
| 129 | finit(fp, fflags, DTYPE_EVENTFD, efd, &eventfdops); |
| 130 | |
| 131 | return (0); |
| 132 | } |
| 133 | |
| 134 | static int |
| 135 | eventfd_close(struct file *fp, struct thread *td) |
no test coverage detected