From 84962fcc9b3a383a0c1d28ab2efb017e8f2ba1b4 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 8 Jan 2022 19:56:52 -0800 Subject: [PATCH] LibPthread: Implement pthread_condattr_getclock I noticed this was missing while adding spec comments a bit ago. It's small and easy enough to implement, might as well make us more POSIX compliant. --- Userland/Libraries/LibPthread/pthread.h | 1 + Userland/Libraries/LibPthread/pthread_cond.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Userland/Libraries/LibPthread/pthread.h b/Userland/Libraries/LibPthread/pthread.h index 68c58afafa..e0cb2cadea 100644 --- a/Userland/Libraries/LibPthread/pthread.h +++ b/Userland/Libraries/LibPthread/pthread.h @@ -90,6 +90,7 @@ int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*); int pthread_cond_signal(pthread_cond_t*); int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); int pthread_condattr_init(pthread_condattr_t*); +int pthread_condattr_getclock(pthread_condattr_t* attr, clockid_t* clock); int pthread_condattr_setclock(pthread_condattr_t*, clockid_t); int pthread_condattr_destroy(pthread_condattr_t*); int pthread_cond_destroy(pthread_cond_t*); diff --git a/Userland/Libraries/LibPthread/pthread_cond.cpp b/Userland/Libraries/LibPthread/pthread_cond.cpp index f46aeeed0d..c6238a6274 100644 --- a/Userland/Libraries/LibPthread/pthread_cond.cpp +++ b/Userland/Libraries/LibPthread/pthread_cond.cpp @@ -29,6 +29,13 @@ int pthread_condattr_destroy(pthread_condattr_t*) return 0; } +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_getclock.html +int pthread_condattr_getclock(pthread_condattr_t* attr, clockid_t* clock) +{ + *clock = attr->clockid; + return 0; +} + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_setclock.html int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock) {