fix build regression due to missing file for putc changes
authorRich Felker <dalias@aerifal.cx>
Thu, 18 Oct 2018 14:43:39 +0000 (10:43 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 18 Oct 2018 14:44:32 +0000 (10:44 -0400)
commit d664061adb4d7f6647ab2059bc351daa394bf5da inadvertently omitted
the new file putc.h.

src/stdio/putc.h [new file with mode: 0644]

diff --git a/src/stdio/putc.h b/src/stdio/putc.h
new file mode 100644 (file)
index 0000000..a37937e
--- /dev/null
@@ -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);
+}