X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fgetc.h;h=e24f9905c1f8c1c360e1a51da7ec515a5a596ae3;hb=e1a51185ceb4386481491e11f6dd39569b9e54f7;hp=0657ab6f65142d94b7370e1f0ffe70013750f657;hpb=dd8f02b7dce53d6b1c4282439f1636a2d63bee01;p=musl diff --git a/src/stdio/getc.h b/src/stdio/getc.h index 0657ab6f..e24f9905 100644 --- a/src/stdio/getc.h +++ b/src/stdio/getc.h @@ -4,9 +4,9 @@ #ifdef __GNUC__ __attribute__((__noinline__)) #endif -static int locking_getc(FILE *f, int tid) +static int locking_getc(FILE *f) { - if (a_cas(&f->lock, 0, tid)) __lockfile(f); + if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); int c = getc_unlocked(f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); @@ -15,8 +15,8 @@ static int locking_getc(FILE *f, int tid) static inline int do_getc(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 getc_unlocked(f); - return locking_getc(f, tid); + return locking_getc(f); }