Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/posix/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut);
* See IEEE 1003.1
*/
int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mut,
const struct timespec *to);
const struct timespec *abstime);

/**
* @brief POSIX threading compatibility API
Expand Down Expand Up @@ -224,7 +224,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m);
*/

int pthread_mutex_timedlock(pthread_mutex_t *m,
const struct timespec *to);
const struct timespec *abstime);

/**
* @brief POSIX threading compatibility API
Expand Down
7 changes: 5 additions & 2 deletions lib/posix/pthread_cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <wait_q.h>
#include <posix/pthread.h>

s64_t timespec_to_timeoutms(const struct timespec *abstime);

static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout)
{
__ASSERT(mut->lock_count == 1U, "");
Expand Down Expand Up @@ -73,8 +75,9 @@ int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut)
}

int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mut,
const struct timespec *to)
const struct timespec *abstime)
{
return cond_wait(cv, mut, _ts_to_ms(to));
s32_t timeout = (s32_t)timespec_to_timeoutms(abstime);
return cond_wait(cv, mut, timeout);
}

7 changes: 5 additions & 2 deletions lib/posix/pthread_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <wait_q.h>
#include <posix/pthread.h>

s64_t timespec_to_timeoutms(const struct timespec *abstime);

#define MUTEX_MAX_REC_LOCK 32767

/*
Expand Down Expand Up @@ -73,9 +75,10 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
* See IEEE 1003.1
*/
int pthread_mutex_timedlock(pthread_mutex_t *m,
const struct timespec *to)
const struct timespec *abstime)
{
return acquire_mutex(m, _ts_to_ms(to));
s32_t timeout = (s32_t)timespec_to_timeoutms(abstime);
return acquire_mutex(m, timeout);
}

/**
Expand Down