X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fputc.h;h=2014c4ec4af9c68c283d5e8cb7b2a094eab436fa;hb=6aeb9c6703670649ee09b3c8575fb428168bb75c;hp=a37937e8715d932bad73067673fc7d791093941f;hpb=ab5e1e340890b95e61d7161d7178c6a26247ad61;p=musl diff --git a/src/stdio/putc.h b/src/stdio/putc.h index a37937e8..2014c4ec 100644 --- a/src/stdio/putc.h +++ b/src/stdio/putc.h @@ -4,9 +4,9 @@ #ifdef __GNUC__ __attribute__((__noinline__)) #endif -static int locking_putc(int c, FILE *f, int tid) +static int locking_putc(int c, FILE *f) { - if (a_cas(&f->lock, 0, tid)) __lockfile(f); + if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); c = putc_unlocked(c, f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); @@ -15,8 +15,8 @@ static int locking_putc(int c, FILE *f, int tid) static inline int do_putc(int c, FILE *f) { - int tid, l = f->lock; - if (l < 0 || (l & ~MAYBE_WAITERS) == (tid=__pthread_self()->tid)) + int l = f->lock; + if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return putc_unlocked(c, f); - return locking_putc(c, f, tid); + return locking_putc(c, f); }