Lines Matching refs:fd
40 int fd; member
45 ret->fd = eventfd(value, EFD_SEMAPHORE); in semaphore_new()
46 if (ret->fd == INVALID_FD) { in semaphore_new()
58 if (semaphore->fd != INVALID_FD) in semaphore_free()
59 close(semaphore->fd); in semaphore_free()
65 assert(semaphore->fd != INVALID_FD); in semaphore_wait()
68 if (eventfd_read(semaphore->fd, &value) == -1) in semaphore_wait()
74 assert(semaphore->fd != INVALID_FD); in semaphore_try_wait()
76 int flags = fcntl(semaphore->fd, F_GETFL); in semaphore_try_wait()
81 if (fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK) == -1) { in semaphore_try_wait()
88 if (eventfd_read(semaphore->fd, &value) == -1) in semaphore_try_wait()
91 if (fcntl(semaphore->fd, F_SETFL, flags) == -1) in semaphore_try_wait()
98 assert(semaphore->fd != INVALID_FD); in semaphore_post()
100 if (eventfd_write(semaphore->fd, 1ULL) == -1) in semaphore_post()
106 assert(semaphore->fd != INVALID_FD); in semaphore_get_fd()
107 return semaphore->fd; in semaphore_get_fd()