getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOW
[musl] / src / thread / pthread_spin_trylock.c
index 1fc5f73..5284fda 100644 (file)
@@ -1,7 +1,7 @@
 #include "pthread_impl.h"
+#include <errno.h>
 
 int pthread_spin_trylock(pthread_spinlock_t *s)
 {
-       if (*s || a_xchg(s, 1)) return EBUSY;
-       return 0;
+       return a_cas(s, 0, EBUSY);
 }