diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-10-18 10:43:39 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-10-18 10:44:32 -0400 |
commit | ab5e1e340890b95e61d7161d7178c6a26247ad61 (patch) | |
tree | 329d97152a9fc9189feb34e5ccc0a3ca89843541 /src/stdio | |
parent | d8f2efa708a027132d443f45a8c98a0c7c1b2d77 (diff) | |
download | musl-ab5e1e340890b95e61d7161d7178c6a26247ad61.tar.gz musl-ab5e1e340890b95e61d7161d7178c6a26247ad61.tar.xz musl-ab5e1e340890b95e61d7161d7178c6a26247ad61.zip |
fix build regression due to missing file for putc changes
commit d664061adb4d7f6647ab2059bc351daa394bf5da inadvertently omitted the new file putc.h.
Diffstat (limited to 'src/stdio')
-rw-r--r-- | src/stdio/putc.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/stdio/putc.h b/src/stdio/putc.h new file mode 100644 index 00000000..a37937e8 --- /dev/null +++ b/src/stdio/putc.h @@ -0,0 +1,22 @@ +#include "stdio_impl.h" +#include "pthread_impl.h" + +#ifdef __GNUC__ +__attribute__((__noinline__)) +#endif +static int locking_putc(int c, FILE *f, int tid) +{ + if (a_cas(&f->lock, 0, tid)) __lockfile(f); + c = putc_unlocked(c, f); + if (a_swap(&f->lock, 0) & MAYBE_WAITERS) + __wake(&f->lock, 1, 1); + return c; +} + +static inline int do_putc(int c, FILE *f) +{ + int tid, l = f->lock; + if (l < 0 || (l & ~MAYBE_WAITERS) == (tid=__pthread_self()->tid)) + return putc_unlocked(c, f); + return locking_putc(c, f, tid); +} |