From: Rich Felker Date: Fri, 25 Mar 2011 03:06:08 +0000 (-0400) Subject: optimize contended case for pthread_spin_trylock X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;ds=sidebyside;h=b8b85a42729dc96e43d51848823fbe28ad92b5c0;p=musl optimize contended case for pthread_spin_trylock --- diff --git a/src/thread/pthread_spin_trylock.c b/src/thread/pthread_spin_trylock.c index c12696b3..1fc5f73c 100644 --- a/src/thread/pthread_spin_trylock.c +++ b/src/thread/pthread_spin_trylock.c @@ -2,5 +2,6 @@ int pthread_spin_trylock(pthread_spinlock_t *s) { - return -a_xchg(s, 1) & EBUSY; + if (*s || a_xchg(s, 1)) return EBUSY; + return 0; }