diff options
Diffstat (limited to 'src/thread/pthread_mutexattr_setrobust.c')
-rw-r--r-- | src/thread/pthread_mutexattr_setrobust.c | 23 |
1 files changed, 23 insertions, 0 deletions
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; +} |