about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile5
-rw-r--r--stdio-common/vfprintf.c21
2 files changed, 16 insertions, 10 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 7fe1987158..4b9ec71338 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -33,6 +33,11 @@ routines	:=							      \
 	tmpfile tmpnam tempnam tempname					      \
 	getline getw putw						      \
 	remove rename
+
+ifneq (,$(filter %REENTRANT, $(defines)))
+routines += lockfile
+endif
+
 aux	:= errlist siglist
 distribute := _itoa.h printf-parse.h
 
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index dc2983d264..1316adacbf 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -124,8 +124,6 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
     }									      \
    while (0)
 # define UNBUFFERED_P(s) ((s)->__buffer == NULL)
-# define __flockfile(S) /* nothing */
-# define __funlockfile(S) /* nothing */
 #endif /* USE_IN_LIBIO */
 
 
@@ -155,6 +153,14 @@ ssize_t __wprintf_pad __P ((FILE *, wchar_t pad, size_t n));
 #endif
 
 
+#ifdef _LIBC_REENTRANT
+extern void __flockfile (FILE *);
+weak_extern (__flockfile);
+extern void __funlockfile (FILE *);
+weak_extern (__funlockfile);
+#endif
+
+
 /* Global variables.  */
 static const char null[] = "(null)";
 
@@ -848,15 +854,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
   f = lead_str_end = find_spec (format, &mbstate);
 
   /* Lock stream.  */
-#ifdef USE_IN_LIBIO
-  __libc_cleanup_region_start ((void (*) (void *)) &_IO_funlockfile, s);
-#else
-#if 0
-  /* XXX For now stdio has no locking.  */
   __libc_cleanup_region_start ((void (*) (void *)) &__funlockfile, s);
-#endif
-#endif
-  __flockfile (s);
+
+  if (__flockfile != NULL)
+    __flockfile (s);
 
   /* Write the literal text before the first format.  */
   outstring ((const UCHAR_T *) format,