diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2002-08-15 22:25:39 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2002-08-15 22:25:39 +0000 |
commit | 6e52332ec743ed97352e296c95cf86395a88f1ae (patch) | |
tree | d869577f3f25537a62302060b582053cc98e25a5 | |
parent | 204250d2fcd0840a6ded28044dc76ab25906445a (diff) | |
download | gcc-6e52332ec743ed97352e296c95cf86395a88f1ae.zip gcc-6e52332ec743ed97352e296c95cf86395a88f1ae.tar.gz gcc-6e52332ec743ed97352e296c95cf86395a88f1ae.tar.bz2 |
re PR libstdc++/7445 (poor performance of std::locale::classic() in multi-threaded applications)
2002-08-15 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/stdio_filebuf.h (stdio_filebuf): Explicitly set
_M_buf_size_opt to zero when unbuffering.
* include/bits/fstream.tcc (filebuf::showmanyc): Simplify.
Consistency checks for _M_buf_size_opt.
Revert PR libstdc++/7445
* src/locale.cc (locale::classic): Revert.
* docs/html/17_intro/TODO: Add.
From-SVN: r56365
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/docs/html/17_intro/TODO | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/stdio_filebuf.h | 20 | ||||
-rw-r--r-- | libstdc++-v3/src/locale.cc | 6 |
5 files changed, 40 insertions, 21 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6b0c957..206d772 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2002-08-15 Benjamin Kosnik <bkoz@redhat.com> + + * include/ext/stdio_filebuf.h (stdio_filebuf): Explicitly set + _M_buf_size_opt to zero when unbuffering. + * include/bits/fstream.tcc (filebuf::showmanyc): Simplify. + Consistency checks for _M_buf_size_opt. + + Revert PR libstdc++/7445 + * src/locale.cc (locale::classic): Revert. + + * docs/html/17_intro/TODO: Add. + 2002-08-15 Phil Edwards <pme@gcc.gnu.org> * docs/html/documentation.html: Update doxygen links for 3.2. diff --git a/libstdc++-v3/docs/html/17_intro/TODO b/libstdc++-v3/docs/html/17_intro/TODO index c7a2ecb..2ba36ad 100644 --- a/libstdc++-v3/docs/html/17_intro/TODO +++ b/libstdc++-v3/docs/html/17_intro/TODO @@ -17,7 +17,16 @@ executable speed. - benchmarking addition to the testsuite that does the above. -- implement symbol versioning for ELF targets. +- implement testing for symbol versioning for ELF targets. + +- review streambuf, filebuf, stringbuf to optimize data member +placement. Do pback bits need to be in streambuf? How about +_M_set_indeterminate, etc? + +- Think about naming all member data and member functions consistently +as per +funtions: _M_verb_adverb +data: _M_noun_adjective - exception specifications need to be reviewed for all parts of the library support and utility areas, particularly <new>. diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 2caeb6e..18dbaf1 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -90,9 +90,8 @@ namespace std { _M_allocate_internal_buffer(); _M_mode = __mode; - - // For time being, set both (in/out) sets of pointers. _M_set_indeterminate(); + if ((__mode & ios_base::ate) && this->seekoff(0, ios_base::end, __mode) < 0) this->close(); @@ -147,12 +146,7 @@ namespace std bool __testin = _M_mode & ios_base::in; if (__testin && this->is_open()) - { - if (_M_in_cur < _M_in_end) - __ret = _M_in_end - _M_in_cur; - else - __ret = 0; - } + __ret = _M_in_end - _M_in_cur; _M_last_overflowed = false; return __ret; } @@ -316,7 +310,7 @@ namespace std { int_type __ret = traits_type::eof(); bool __testput = _M_out_cur && _M_out_beg < _M_out_end; - bool __testunbuffered = _M_file.is_open() && !_M_buf_size; + bool __testunbuffered = _M_file.is_open() && !_M_buf_size_opt; if (__testput || __testunbuffered) { diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h index cd869a8..59ab41a 100644 --- a/libstdc++-v3/include/ext/stdio_filebuf.h +++ b/libstdc++-v3/include/ext/stdio_filebuf.h @@ -123,16 +123,18 @@ namespace __gnu_cxx if (this->is_open()) { _M_mode = __mode; - _M_buf_size_opt = __size; - if (__size > 0 && __size < 4) { + // Specify unbuffered. _M_buf = _M_unbuf; _M_buf_size = __size; + _M_buf_size_opt = 0; } else - _M_allocate_internal_buffer(); - + { + _M_buf_size_opt = __size; + _M_allocate_internal_buffer(); + } _M_set_indeterminate(); } } @@ -146,16 +148,18 @@ namespace __gnu_cxx if (this->is_open()) { _M_mode = __mode; - _M_buf_size_opt = __size; - if (__size > 0 && __size < 4) { + // Specify unbuffered. _M_buf = _M_unbuf; _M_buf_size = __size; + _M_buf_size_opt = 0; } else - _M_allocate_internal_buffer(); - + { + _M_buf_size_opt = __size; + _M_allocate_internal_buffer(); + } _M_set_indeterminate(); } } diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 3c755bb..3cb9d1b 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -284,11 +284,11 @@ namespace std const locale& locale::classic() { + static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER; + _STL_auto_lock __auto(__lock); + if (!_S_classic) { - static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER; - _STL_auto_lock __auto(__lock); - try { // 26 Standard facets, 2 references. |