44 err =
rc == 0 ? 0 : errno;
53 rc = sem_destroy(&semaphore->
s_sem);
62 rc = sem_wait(&semaphore->
s_sem);
63 while (
rc == -1 && errno == EINTR);
71 rc = sem_post(&semaphore->
s_sem);
80 rc = sem_trywait(&semaphore->
s_sem);
81 while (
rc == -1 && errno == EINTR);
83 "rc=%d errno=%d",
rc, errno);
93 rc = sem_getvalue(&semaphore->
s_sem, &result);
103 struct timespec ts = {
122 ts.tv_sec =
min_check(ts.tv_sec, (time_t)(INT_MAX - 1));
126 rc = sem_timedwait(&semaphore->
s_sem, &ts);
127 while (
rc == -1 && errno == EINTR);
129 "rc=%d errno=%d",
rc, errno);
130 if (
rc == -1 && errno == ETIMEDOUT)
M0_INTERNAL bool m0_semaphore_trydown(struct m0_semaphore *semaphore)
M0_INTERNAL bool m0_semaphore_timeddown(struct m0_semaphore *semaphore, const m0_time_t abs_timeout)
uint64_t m0_time_nanoseconds(const m0_time_t time)
int const char const void * value
M0_INTERNAL unsigned m0_semaphore_value(struct m0_semaphore *semaphore)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
uint64_t m0_time_seconds(const m0_time_t time)
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
#define M0_ASSERT_INFO(cond, fmt,...)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
M0_INTERNAL m0_time_t m0_time_to_realtime(m0_time_t abs_time)