X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2F__lock.c;h=0874c04a4c0a81a9fa0dc032479ec18cec81d8aa;hb=513136efa4274c39ed1c071ae4f4f2b10118f9f5;hp=2f345ae7af02153c1bffbd5cbfc0f0be860127a6;hpb=4750cf4202c29a895639b89099a7bdbe9ae422b6;p=musl diff --git a/src/thread/__lock.c b/src/thread/__lock.c index 2f345ae7..0874c04a 100644 --- a/src/thread/__lock.c +++ b/src/thread/__lock.c @@ -2,11 +2,14 @@ void __lock(volatile int *l) { - while (a_swap(l, 1)) __wait(l, l+1, 1, 1); + if (libc.threads_minus_1) + while (a_swap(l, 1)) __wait(l, l+1, 1, 1); } void __unlock(volatile int *l) { - a_store(l, 0); - if (l[1]) __wake(l, 1, 1); + if (l[0]) { + a_store(l, 0); + if (l[1]) __wake(l, 1, 1); + } }