From 26a8a84ded000ea42ecd0ae236cc5c452fd67df7 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 13 Feb 2021 12:06:05 +0330 Subject: [PATCH] LibC+LibPthread: Stub out pthread_rwlock_* functions --- Userland/Libraries/LibC/sys/types.h | 2 +- Userland/Libraries/LibPthread/pthread.cpp | 57 +++++++++++++++++++++++ Userland/Libraries/LibPthread/pthread.h | 18 +++++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/sys/types.h b/Userland/Libraries/LibC/sys/types.h index af1f4fb32a..9ee36152ba 100644 --- a/Userland/Libraries/LibC/sys/types.h +++ b/Userland/Libraries/LibC/sys/types.h @@ -99,7 +99,7 @@ typedef struct __pthread_cond_t { } pthread_cond_t; typedef void* pthread_rwlock_t; -typedef void* pthread_rwlockatrr_t; +typedef void* pthread_rwlockattr_t; typedef void* pthread_spinlock_t; typedef struct __pthread_condattr_t { int clockid; // clockid_t diff --git a/Userland/Libraries/LibPthread/pthread.cpp b/Userland/Libraries/LibPthread/pthread.cpp index b4b5240efa..1dc878f210 100644 --- a/Userland/Libraries/LibPthread/pthread.cpp +++ b/Userland/Libraries/LibPthread/pthread.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -683,4 +685,59 @@ int pthread_equal(pthread_t t1, pthread_t t2) return t1 == t2; } +int pthread_rwlock_destroy(pthread_rwlock_t* rl) +{ + if (!rl) + return 0; + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_init(pthread_rwlock_t* __restrict, const pthread_rwlockattr_t* __restrict) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_rdlock(pthread_rwlock_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_timedrdlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_timedwrlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_tryrdlock(pthread_rwlock_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_trywrlock(pthread_rwlock_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_unlock(pthread_rwlock_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlock_wrlock(pthread_rwlock_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlockattr_destroy(pthread_rwlockattr_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* __restrict, int* __restrict) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlockattr_init(pthread_rwlockattr_t*) +{ + ASSERT_NOT_REACHED(); +} +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int) +{ + ASSERT_NOT_REACHED(); +} + } // extern "C" diff --git a/Userland/Libraries/LibPthread/pthread.h b/Userland/Libraries/LibPthread/pthread.h index 67e6300911..5994ae1009 100644 --- a/Userland/Libraries/LibPthread/pthread.h +++ b/Userland/Libraries/LibPthread/pthread.h @@ -87,6 +87,10 @@ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param 0, 0, CLOCK_MONOTONIC_COARSE \ } +// FIXME: Actually implement this! +#define PTHREAD_RWLOCK_INITIALIZER \ + NULL + #define PTHREAD_KEYS_MAX 64 #define PTHREAD_DESTRUCTOR_ITERATIONS 4 @@ -127,4 +131,18 @@ int pthread_getname_np(pthread_t, char*, size_t); int pthread_equal(pthread_t t1, pthread_t t2); +int pthread_rwlock_destroy(pthread_rwlock_t*); +int pthread_rwlock_init(pthread_rwlock_t* __restrict, const pthread_rwlockattr_t* __restrict); +int pthread_rwlock_rdlock(pthread_rwlock_t*); +int pthread_rwlock_timedrdlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict); +int pthread_rwlock_timedwrlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict); +int pthread_rwlock_tryrdlock(pthread_rwlock_t*); +int pthread_rwlock_trywrlock(pthread_rwlock_t*); +int pthread_rwlock_unlock(pthread_rwlock_t*); +int pthread_rwlock_wrlock(pthread_rwlock_t*); +int pthread_rwlockattr_destroy(pthread_rwlockattr_t*); +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* __restrict, int* __restrict); +int pthread_rwlockattr_init(pthread_rwlockattr_t*); +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int); + __END_DECLS