summaryrefslogtreecommitdiff
path: root/src/thread/pthread_rwlock_wrlock.c
blob: 8fd9ad1de1cbc0aa406c983eef12ba3cf2fc6380 (plain) (blame)
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->_rw_readers))
			__wait(&rw->_rw_readers, &rw->_rw_waiters, nr, 0);
		else
			__wait(&rw->_rw_wrlock, &rw->_rw_waiters, 1, 0);
	}
	return 0;
}