Quellcode durchsuchen

optimize contended case for pthread_spin_trylock

Rich Felker vor 14 Jahren
Ursprung
Commit
b8b85a4272
1 geänderte Dateien mit 2 neuen und 1 gelöschten Zeilen
  1. 2 1
      src/thread/pthread_spin_trylock.c

+ 2 - 1
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;
 }