aboutsummaryrefslogtreecommitdiff
path: root/src/thread/pthread_mutexattr_setrobust.c
blob: 8f835ff18487a51771d2c6a010e4ea787add66b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif