• Home
  • Raw
  • Download

Lines Matching refs:semaphore

54 void semaphore_free(semaphore_t* semaphore) {  in semaphore_free()  argument
55 if (!semaphore) return; in semaphore_free()
57 if (semaphore->fd != INVALID_FD) close(semaphore->fd); in semaphore_free()
58 osi_free(semaphore); in semaphore_free()
61 void semaphore_wait(semaphore_t* semaphore) { in semaphore_wait() argument
62 CHECK(semaphore != NULL); in semaphore_wait()
63 CHECK(semaphore->fd != INVALID_FD); in semaphore_wait()
66 if (eventfd_read(semaphore->fd, &value) == -1) in semaphore_wait()
70 bool semaphore_try_wait(semaphore_t* semaphore) { in semaphore_try_wait() argument
71 CHECK(semaphore != NULL); in semaphore_try_wait()
72 CHECK(semaphore->fd != INVALID_FD); in semaphore_try_wait()
74 int flags = fcntl(semaphore->fd, F_GETFL); in semaphore_try_wait()
80 if (fcntl(semaphore->fd, F_SETFL, flags | O_NONBLOCK) == -1) { in semaphore_try_wait()
88 if (eventfd_read(semaphore->fd, &value) == -1) rc = false; in semaphore_try_wait()
90 if (fcntl(semaphore->fd, F_SETFL, flags) == -1) in semaphore_try_wait()
96 void semaphore_post(semaphore_t* semaphore) { in semaphore_post() argument
97 CHECK(semaphore != NULL); in semaphore_post()
98 CHECK(semaphore->fd != INVALID_FD); in semaphore_post()
100 if (eventfd_write(semaphore->fd, 1ULL) == -1) in semaphore_post()
104 int semaphore_get_fd(const semaphore_t* semaphore) { in semaphore_get_fd() argument
105 CHECK(semaphore != NULL); in semaphore_get_fd()
106 CHECK(semaphore->fd != INVALID_FD); in semaphore_get_fd()
107 return semaphore->fd; in semaphore_get_fd()