Make libio compile without _IO_MTSAFE_IO.
authorRoland McGrath <roland@hack.frob.com>
Fri, 17 Aug 2012 16:35:36 +0000 (09:35 -0700)
committerRoland McGrath <roland@hack.frob.com>
Fri, 17 Aug 2012 16:35:36 +0000 (09:35 -0700)
ChangeLog
libio/genops.c
libio/libioP.h
misc/Makefile
nptl/ChangeLog
nptl/sysdeps/unix/sysv/linux/Makefile

index 3e37db9..9d8543c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2012-08-17  Roland McGrath  <roland@hack.frob.com>
 
+       * libio/genops.c (_IO_unbuffer_write): Conditionalize locking code on
+       [_IO_MTSAFE_IO].
+       * libio/libioP.h [!_IO_MTSAFE_IO && !NOT_IN_libc]
+       (_IO_acquire_lock, _IO_acquire_lock_clear_flags2, _IO_release_lock):
+       New macros.
+
        * Makeconfig [$(libc-reentrant) = yes] (libio-mtsafe): New variable.
        * libio/Makefile (CPPFLAGS): Append $(libio-mtsafe) unconditionally
        rather than -D_IO_MTSAFE_IO conditionally.
index c8297ff..0a81a5d 100644 (file)
@@ -952,6 +952,7 @@ _IO_unbuffer_write (void)
          /* Iff stream is un-orientated, it wasn't used. */
          && fp->_mode != 0)
        {
+#ifdef _IO_MTSAFE_IO
          int cnt;
 #define MAXTRIES 2
          for (cnt = 0; cnt < MAXTRIES; ++cnt)
@@ -961,6 +962,7 @@ _IO_unbuffer_write (void)
              /* Give the other thread time to finish up its use of the
                 stream.  */
              __sched_yield ();
+#endif
 
          if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
            {
@@ -974,8 +976,10 @@ _IO_unbuffer_write (void)
 
          _IO_SETBUF (fp, NULL, 0);
 
+#ifdef _IO_MTSAFE_IO
          if (cnt < MAXTRIES && fp->_lock != NULL)
            _IO_lock_unlock (*fp->_lock);
+#endif
        }
 
       /* Make sure that never again the wide char functions can be
index 486c670..aa2b3bf 100644 (file)
@@ -933,3 +933,17 @@ _IO_acquire_lock_clear_flags2_fct (_IO_FILE **p)
   if ((fp->_flags & _IO_USER_LOCK) == 0)
     _IO_funlockfile (fp);
 }
+
+#if !defined _IO_MTSAFE_IO && !defined NOT_IN_libc
+# define _IO_acquire_lock(_fp)                                               \
+  do {                                                                       \
+    _IO_FILE *_IO_acquire_lock_file = NULL
+# define _IO_acquire_lock_clear_flags2(_fp)                                  \
+  do {                                                                       \
+    _IO_FILE *_IO_acquire_lock_file = (_fp)
+# define _IO_release_lock(_fp)                                               \
+    if (_IO_acquire_lock_file != NULL)                                       \
+      _IO_acquire_lock_file->_flags2 &= ~(_IO_FLAGS2_FORTIFY                 \
+                                          | _IO_FLAGS2_SCANF_STD);           \
+  } while (0)
+#endif
index d1c0a02..d35654c 100644 (file)
@@ -95,7 +95,6 @@ CFLAGS-getsysstats.c = -fexceptions
 CFLAGS-getusershell.c = -fexceptions
 CFLAGS-err.c = -fexceptions
 CFLAGS-tst-tsearch.c = $(stack-align-test-flags)
-CFLAGS-mntent_r.c = -D_IO_MTSAFE_IO
 
 include ../Rules
 
index 8a8cbb8..eb84863 100644 (file)
@@ -1,8 +1,13 @@
 2012-08-15  Roland McGrath  <roland@hack.frob.com>
 
+2012-08-15  Roland McGrath  <roland@hack.frob.com>
+
+2012-08-15  Roland McGrath  <roland@hack.frob.com>
+
        * Makefile (CFLAGS-flockfile.c): Use $(libio-mtsafe) instead
        of -D_IO_MTSAFE_IO.
        (CFLAGS-ftrylockfile.c, CFLAGS-funlockfile.c): Likewise.
+       * sysdeps/unix/sysv/linux/Makefile (CFLAGS-fork.c): Likewise.
 
 2012-08-16  Joseph Myers  <joseph@codesourcery.com>
 
index 64a3f4f..d24a9bc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -29,7 +29,7 @@ gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \
 endif
 
 ifeq ($(subdir),posix)
-CFLAGS-fork.c = -D_IO_MTSAFE_IO
+CFLAGS-fork.c = $(libio-mtsafe)
 CFLAGS-getpid.o = -fomit-frame-pointer
 CFLAGS-getpid.os = -fomit-frame-pointer
 endif