summaryrefslogtreecommitdiff
path: root/libc/stdio/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio/printf.c')
-rw-r--r--libc/stdio/printf.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c
index 9654cda90..5bdec7ae4 100644
--- a/libc/stdio/printf.c
+++ b/libc/stdio/printf.c
@@ -1265,6 +1265,10 @@ int vsnprintf(char *__restrict buf, size_t size,
f.filedes = -2; /* for debugging */
f.modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
+#ifdef __STDIO_THREADSAFE
+ __stdio_init_mutex(&f.lock);
+#endif
+
rv = vfprintf(&f, format, arg);
if (size) {
if (f.bufwpos == f.bufend) {
@@ -1335,6 +1339,10 @@ int vsnprintf(char *__restrict buf, size_t size,
f.filedes = -1; /* For debugging. */
f.modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
+#ifdef __STDIO_THREADSAFE
+ __stdio_init_mutex(&f.lock);
+#endif
+
rv = vfprintf(&f, format, arg);
return rv;
@@ -1373,6 +1381,10 @@ int vdprintf(int filedes, const char * __restrict format, va_list arg)
f.filedes = filedes;
f.modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
+#ifdef __STDIO_THREADSAFE
+ __stdio_init_mutex(&f.lock);
+#endif
+
rv = vfprintf(&f, format, arg);
return fflush(&f) ? -1 : rv;