File:  [DVB] / dietlibc / libpthread / pthread_rwlock_tryrdlock.c
Revision 1.1: download - view: text, annotated - select for diffs
Sat Aug 27 17:35:13 2016 UTC (7 years, 9 months ago) by leitner
Branches: MAIN
CVS tags: HEAD
  add really crappy pthread_rwclock implementation for openssl 1.1

#include <pthread.h>
#include <errno.h>

int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) {
  unsigned int cur;
  do {
    cur=rwlock->n;
    if (cur&0x80000000)
      return EBUSY;
    if (cur>=0x10000000)
      return EAGAIN;
  } while (!__sync_bool_compare_and_swap(&rwlock->n,cur,cur+1));
  return 0;
}

LinuxTV legacy CVS <linuxtv.org/cvs>