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

int pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
{
	a_inc(&rw->__readers);
	if (rw->__wrlock) {
		a_dec(&rw->__readers);
		if (rw->__waiters && !rw->__readers)
			__wake(&rw->__readers, 1, 0);
		return EAGAIN;
	}
	return 0;
}