This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH roland/libio-mtsafe] make libio compile without _IO_MTSAFE_IO


This turned out to be all it took to get libio code to compile without
_IO_MTSAFE_IO defined.  It's on the same branch with the previous change.

I forgot to mention for the last one that I'd verified that on
x86_64-linux-gnu it had no effect at all on compiled code.

If nobody has a problem with or objection to this branch in the next day or
two, I'll merge it in.


Thanks,
Roland


	* 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.


diff --git a/libio/genops.c b/libio/genops.c
index c8297ff..0a81a5d 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -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
diff --git a/libio/libioP.h b/libio/libioP.h
index 486c670..aa2b3bf 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]