From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/thread/pthread_mutexattr_setrobust.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/thread/pthread_mutexattr_setrobust.c (limited to 'src/thread/pthread_mutexattr_setrobust.c') diff --git a/src/thread/pthread_mutexattr_setrobust.c b/src/thread/pthread_mutexattr_setrobust.c new file mode 100644 index 0000000..30a9ac3 --- /dev/null +++ b/src/thread/pthread_mutexattr_setrobust.c @@ -0,0 +1,23 @@ +#include "pthread_impl.h" +#include "syscall.h" + +static volatile int check_robust_result = -1; + +int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) +{ + if (robust > 1U) return EINVAL; + if (robust) { + int r = check_robust_result; + if (r < 0) { + void *p; + size_t l; + r = -__syscall(SYS_get_robust_list, 0, &p, &l); + a_store(&check_robust_result, r); + } + if (r) return r; + a->__attr |= 4; + return 0; + } + a->__attr &= ~4; + return 0; +} -- cgit v1.2.3