diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-03-24 23:06:08 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-03-24 23:06:08 -0400 |
commit | b8b85a42729dc96e43d51848823fbe28ad92b5c0 (patch) | |
tree | e4283410cf7a5da198ca1171c240b78ac76adbb3 /src | |
parent | c322fe4e1a9bcc20f7a2ded1ac0e1674ea282bc0 (diff) | |
download | musl-b8b85a42729dc96e43d51848823fbe28ad92b5c0.tar.gz musl-b8b85a42729dc96e43d51848823fbe28ad92b5c0.tar.xz musl-b8b85a42729dc96e43d51848823fbe28ad92b5c0.zip |
optimize contended case for pthread_spin_trylock
Diffstat (limited to 'src')
-rw-r--r-- | src/thread/pthread_spin_trylock.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; } |