From cecb282ed331701073fd76196ddb734b0f14ec47 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Mon, 1 Apr 2002 15:16:54 +0000 Subject: Forget to initialize thread locks for fake files. Thanks Erik. --- libc/stdio/printf.c | 12 ++++++++++++ libc/stdio/scanf.c | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'libc/stdio') 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; diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c index 07e74d9ae..a5e0d412c 100644 --- a/libc/stdio/scanf.c +++ b/libc/stdio/scanf.c @@ -127,6 +127,10 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) string->bufstart = string->bufrpos = (unsigned char *) ((void *) sp); string->bufgetc = (char *) ((unsigned) -1); +#ifdef __STDIO_THREADSAFE + __stdio_init_mutex(&string->lock); +#endif + return vfscanf(string, fmt, ap); } #else /* __STDIO_BUFFERS */ -- cgit v1.2.3