Lines Matching +defs:val +defs:state
35 kmutex_t efd_lock; /* lock protecting state */
41 eventfd_state_t *efd_next; /* next state on global list */
47 static kmutex_t eventfd_lock; /* lock protecting state */
51 static eventfd_state_t *eventfd_state; /* global list of state */
57 eventfd_state_t *state;
75 state = ddi_get_soft_state(eventfd_softstate, minor);
78 state->efd_next = eventfd_state;
79 eventfd_state = state;
90 eventfd_state_t *state;
92 uint64_t val, oval;
95 if (uio->uio_resid < sizeof (val))
98 state = ddi_get_soft_state(eventfd_softstate, minor);
100 mutex_enter(&state->efd_lock);
102 while (state->efd_value == 0) {
104 mutex_exit(&state->efd_lock);
108 if (!cv_wait_sig_swap(&state->efd_cv, &state->efd_lock)) {
109 mutex_exit(&state->efd_lock);
119 val = oval = state->efd_value;
121 if (state->efd_semaphore) {
122 state->efd_value--;
123 val = 1;
125 state->efd_value = 0;
128 err = uiomove(&val, sizeof (val), UIO_READ, uio);
134 if (state->efd_bwriters != 0) {
135 cv_broadcast(&state->efd_cv);
137 mutex_exit(&state->efd_lock);
145 pollwakeup(&state->efd_pollhd, POLLWRNORM | POLLOUT);
155 eventfd_state_t *state;
157 uint64_t val, oval;
160 if (uio->uio_resid < sizeof (val))
163 if ((err = uiomove(&val, sizeof (val), UIO_WRITE, uio)) != 0)
166 if (val > EVENTFD_VALMAX)
169 state = ddi_get_soft_state(eventfd_softstate, minor);
171 mutex_enter(&state->efd_lock);
173 while (val > EVENTFD_VALMAX - state->efd_value) {
175 mutex_exit(&state->efd_lock);
179 state->efd_bwriters++;
180 if (!cv_wait_sig_swap(&state->efd_cv, &state->efd_lock)) {
181 state->efd_bwriters--;
182 mutex_exit(&state->efd_lock);
185 state->efd_bwriters--;
191 state->efd_value = (oval = state->efd_value) + val;
198 cv_broadcast(&state->efd_cv);
200 mutex_exit(&state->efd_lock);
206 pollwakeup(&state->efd_pollhd, POLLRDNORM | POLLIN);
217 eventfd_state_t *state;
221 state = ddi_get_soft_state(eventfd_softstate, minor);
223 mutex_enter(&state->efd_lock);
225 if (state->efd_value > 0)
228 if (state->efd_value < EVENTFD_VALMAX)
232 *phpp = &state->efd_pollhd;
234 mutex_exit(&state->efd_lock);
243 eventfd_state_t *state;
246 state = ddi_get_soft_state(eventfd_softstate, minor);
250 mutex_enter(&state->efd_lock);
251 state->efd_semaphore ^= 1;
252 mutex_exit(&state->efd_lock);
268 eventfd_state_t *state, **sp;
271 state = ddi_get_soft_state(eventfd_softstate, minor);
273 if (state->efd_pollhd.ph_list != NULL) {
274 pollwakeup(&state->efd_pollhd, POLLERR);
275 pollhead_clean(&state->efd_pollhd);
281 * Remove our state from our global list.
283 for (sp = &eventfd_state; *sp != state; sp = &((*sp)->efd_next))
314 cmn_err(CE_NOTE, "/dev/eventfd failed to create soft state");