| 1 | #include "pthread_impl.h" |
| 2 | #include "syscall.h" |
| 3 | |
| 4 | static volatile int check_robust_result = -1; |
| 5 | |
| 6 | int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) |
| 7 | { |
| 8 | #ifdef __wasilibc_unmodified_upstream |
| 9 | 	if (robust > 1U) return EINVAL; |
| 10 | 	if (robust) { |
| 11 | 		int r = check_robust_result; |
| 12 | 		if (r < 0) { |
| 13 | 			void *p; |
| 14 | 			size_t l; |
| 15 | 			r = -__syscall(SYS_get_robust_list, 0, &p, &l); |
| 16 | 			a_store(&check_robust_result, r); |
| 17 | 		} |
| 18 | 		if (r) return r; |
| 19 | 		a->__attr |= 4; |
| 20 | 		return 0; |
| 21 | 	} |
| 22 | 	a->__attr &= ~4; |
| 23 | 	return 0; |
| 24 | #else |
| 25 | 	if (robust) return EINVAL; |
| 26 | 	return 0; |
| 27 | #endif |
| 28 | } |