From: Ulrich Drepper Date: Wed, 28 Nov 2001 23:36:24 +0000 (+0000) Subject: (_IO_flush_all_lockp): New function. The same code X-Git-Tag: cvs/glibc-2-2-5~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baa468f10495a628d77ecc8e086ae6134a9c67ca;p=thirdparty%2Fglibc.git (_IO_flush_all_lockp): New function. The same code as the old _IO_flush_all but lock only if parameter is nonzero. (_IO_flush_all): Call _IO_flush_all_lockp with 1 as parameter. --- diff --git a/libio/genops.c b/libio/genops.c index d786ebca577..2398cff6844 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -784,7 +784,7 @@ _IO_get_column (fp) int -_IO_flush_all () +_IO_flush_all_lockp (int do_lock) { int result = 0; struct _IO_FILE *fp; @@ -792,7 +792,8 @@ _IO_flush_all () #ifdef _IO_MTSAFE_IO _IO_cleanup_region_start_noarg (flush_cleanup); - _IO_lock_lock (list_all_lock); + if (do_lock) + _IO_lock_lock (list_all_lock); #endif last_stamp = _IO_list_all_stamp; @@ -800,7 +801,8 @@ _IO_flush_all () while (fp != NULL) { run_fp = fp; - _IO_flockfile (fp); + if (do_lock) + _IO_flockfile (fp); if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base) #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T @@ -812,7 +814,8 @@ _IO_flush_all () && _IO_OVERFLOW (fp, EOF) == EOF) result = EOF; - _IO_funlockfile (fp); + if (do_lock) + _IO_funlockfile (fp); run_fp = NULL; if (last_stamp != _IO_list_all_stamp) @@ -826,13 +829,22 @@ _IO_flush_all () } #ifdef _IO_MTSAFE_IO - _IO_lock_unlock (list_all_lock); + if (do_lock) + _IO_lock_unlock (list_all_lock); _IO_cleanup_region_end (0); #endif return result; } + +int +_IO_flush_all () +{ + /* We want locking. */ + return _IO_flush_all_lockp (1); +} + void _IO_flush_all_linebuffered () {