diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-16 01:39:48 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-16 01:39:48 +0000 |
| commit | a500a5e534b3c03c685f3397050afe6667b740f8 (patch) | |
| tree | 83f861ead0b110d83f940af7b4001c60752caac9 /src/libstddjb | |
| parent | 9c25f19fa75504d8cbcd60737677e7f99341442b (diff) | |
| download | skalibs-a500a5e534b3c03c685f3397050afe6667b740f8.tar.gz | |
Add phread_mutex_clocklock() sysdep, pthread_mutex_tailock() function
Diffstat (limited to 'src/libstddjb')
| -rw-r--r-- | src/libstddjb/pthread_mutex_tailock.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstddjb/pthread_mutex_tailock.c b/src/libstddjb/pthread_mutex_tailock.c new file mode 100644 index 0000000..affa8b3 --- /dev/null +++ b/src/libstddjb/pthread_mutex_tailock.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include <errno.h> +#include <time.h> +#include <pthread.h> + +#include <skalibs/sysdeps.h> +#include <skalibs/tai.h> +#include <skalibs/pthread.h> + +int pthread_mutex_tailock (pthread_mutex_t *mtx, tain const *deadline, tain *stamp) +{ + struct timespec ts ; + tain tto ; + tain_sub(&tto, deadline, stamp) ; + if (!timespec_from_tain_relative(&ts, &tto)) return errno ; +#ifdef SKALIBS_HASPTHREADMUTEXCLOCKLOCK + if (&tain_now != &tain_wallclock_read) + return pthread_mutex_clocklock(mtx, CLOCK_MONOTONIC, &ts) ; + else +#else + return pthread_mutex_timedlock(mtx, &ts) ; +#endif +} |
