summaryrefslogtreecommitdiff
path: root/src/thread/pthread_rwlock_wrlock.c
blob: 219e924a5bbd14920f7323692c08933835d38ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "pthread_impl.h"

int pthread_rwlock_wrlock(pthread_rwlock_t *rw)
{
	int nr;
	while (pthread_rwlock_trywrlock(rw)==EAGAIN) {
		if ((nr=rw->__readers))
			__wait(&rw->__readers, &rw->__waiters, nr, 0);
		else
			__wait(&rw->__wrlock, &rw->__waiters, 1, 0);
	}
	return 0;
}