2005-07-22 Jakub Jelinek * src/sstream-inst.cc: Add .hidden directive for streamsize basic_stringbuf<{char,wchar_t}>::showmanyc(). * src/sstream-inst-showmanyc.cc: New file. * src/Makefile.am (libstdc++_nonshared.la): Add new library. * src/Makefile.in: Rebuilt. * testsuite/lib/libstdc++.exp: Append -lstdc++_nonshared for testsuite executable linking. 2005-06-08 Benjamin Kosnik PR libstdc++/21955 * include/std/std_sstream.h (basic_stringbuf::showmanyc): Add. * testsuite/27_io/basic_streambuf/in_avail/char/1.cc: New, test base class behavior. * testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc: Same. * testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc: New. * testsuite/27_io/basic_stringbuf/in_avail/char/1.cc: Match filebuf behavior. * testsuite/27_io/basic_stringbuf/str/char/1.cc: Same. --- libstdc++-v3/src/sstream-inst.cc.jj 2003-07-11 10:28:13.000000000 +0200 +++ libstdc++-v3/src/sstream-inst.cc 2005-07-21 17:46:08.000000000 +0200 @@ -60,3 +60,8 @@ namespace std template class basic_stringstream; #endif } // namespace std + +#ifdef PIC +__asm (".hidden _ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE9showmanycEv"); +__asm (".hidden _ZNSt15basic_stringbufIwSt11char_traitsIwESaIwEE9showmanycEv"); +#endif --- libstdc++-v3/src/sstream-inst-showmanyc.cc.jj 2005-07-21 21:27:40.000000000 +0200 +++ libstdc++-v3/src/sstream-inst-showmanyc.cc 2005-07-22 09:16:58.000000000 +0200 @@ -0,0 +1,39 @@ +// Explicit instantiation file. + +// Copyright (C) 2005 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include + +namespace std +{ + // These symbols are hidden in libstdc++.so, as it is undesirable to export + // @@GLIBCXX_3.4.6 + template streamsize basic_stringbuf, allocator >::showmanyc(); + template streamsize basic_stringbuf, allocator >::showmanyc(); +} // namespace std --- libstdc++-v3/src/Makefile.am.jj 2004-04-20 15:55:47.000000000 +0200 +++ libstdc++-v3/src/Makefile.am 2005-07-22 09:00:32.000000000 +0200 @@ -25,7 +25,7 @@ include $(top_srcdir)/fragment.am # Cross compiler support. -toolexeclib_LTLIBRARIES = libstdc++.la +toolexeclib_LTLIBRARIES = libstdc++.la libstdc++_nonshared.la # Symbol versioning for shared libraries. if GLIBCXX_BUILD_VERSIONED_SHLIB @@ -150,6 +150,11 @@ libstdc___la_DEPENDENCIES = ${version_de libstdc___la_LDFLAGS = \ -version-info $(libtool_VERSION) ${version_arg} -lm +libstdc___nonshared_la_SOURCES = \ + sstream-inst-showmanyc.cc +libstdc___nonshared_la_LIBADD = +libstdc___nonshared_la_DEPENDENCIES = $(libstdc___nonshared_la_LIBADD) +libstdc___nonshared_la_LDFLAGS = -static # Use special rules for the deprecated source files so that they find # deprecated include files. @@ -159,6 +164,14 @@ strstream.lo: strstream.cc strstream.o: strstream.cc $(CXXCOMPILE) -I$(GLIBCXX_INCLUDE_DIR)/backward -Wno-deprecated -c $< +# Use special rules for libstdc++_nonshared.la files, as -prefer-pic +# doesn't seem to work for some reason. +sstream-inst-showmanyc.lo: sstream-inst-showmanyc.cc + $(LTCXXCOMPILE) -c $< \ + && cp -f .libs/sstream-inst-showmanyc.o sstream-inst-showmanyc.o +sstream-inst-showmanyc.o: sstream-inst-showmanyc.cc + $(CXXCOMPILE) -fPIC -DPIC -c $< + # Use special rules for the concept-checking instantiations so that all # the generated template functions are also instantiated. Force the checks # to be on so that the instantiations are actually seen. --- libstdc++-v3/src/Makefile.in.jj 2004-04-20 15:55:47.000000000 +0200 +++ libstdc++-v3/src/Makefile.in 2005-07-22 09:06:15.000000000 +0200 @@ -221,7 +221,7 @@ WARN_CXXFLAGS = \ AM_CPPFLAGS = $(GLIBCXX_INCLUDES) # Cross compiler support. -toolexeclib_LTLIBRARIES = libstdc++.la +toolexeclib_LTLIBRARIES = libstdc++.la libstdc++_nonshared.la # Symbol versioning for shared libraries. @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_arg = -Wl,--version-script=libstdc++-symbol.ver @@ -308,6 +308,13 @@ libstdc___la_LDFLAGS = \ -version-info $(libtool_VERSION) ${version_arg} -lm +libstdc___nonshared_la_SOURCES = \ + sstream-inst-showmanyc.cc + +libstdc___nonshared_la_LIBADD = +libstdc___nonshared_la_DEPENDENCIES = $(libstdc___nonshared_la_LIBADD) +libstdc___nonshared_la_LDFLAGS = -static + # Use special rules for the deprecated source files so that they find # deprecated include files. GLIBCXX_INCLUDE_DIR = $(glibcxx_builddir)/include @@ -379,6 +386,8 @@ am__objects_3 = allocator.lo codecvt.lo $(am__objects_1) $(am__objects_2) am_libstdc___la_OBJECTS = $(am__objects_3) libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS) +am_libstdc___nonshared_la_OBJECTS = sstream-inst-showmanyc.lo +libstdc___nonshared_la_OBJECTS = $(am_libstdc___nonshared_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = @@ -386,10 +395,10 @@ am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) -DIST_SOURCES = $(libstdc___la_SOURCES) +DIST_SOURCES = $(libstdc___la_SOURCES) $(libstdc___nonshared_la_SOURCES) DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/fragment.am \ Makefile.am -SOURCES = $(libstdc___la_SOURCES) +SOURCES = $(libstdc___la_SOURCES) $(libstdc___nonshared_la_SOURCES) all: all-am @@ -430,6 +439,8 @@ clean-toolexeclibLTLIBRARIES: done libstdc++.la: $(libstdc___la_OBJECTS) $(libstdc___la_DEPENDENCIES) $(CXXLINK) -rpath $(toolexeclibdir) $(libstdc___la_LDFLAGS) $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD) $(LIBS) +libstdc++_nonshared.la: $(libstdc___nonshared_la_OBJECTS) $(libstdc___nonshared_la_DEPENDENCIES) + $(CXXLINK) -rpath $(toolexeclibdir) $(libstdc___nonshared_la_LDFLAGS) $(libstdc___nonshared_la_OBJECTS) $(libstdc___nonshared_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core @@ -674,6 +685,14 @@ strstream.lo: strstream.cc strstream.o: strstream.cc $(CXXCOMPILE) -I$(GLIBCXX_INCLUDE_DIR)/backward -Wno-deprecated -c $< +# Use special rules for libstdc++_nonshared.la files, as -prefer-pic +# doesn't seem to work for some reason. +sstream-inst-showmanyc.lo: sstream-inst-showmanyc.cc + $(LTCXXCOMPILE) -c $< \ + && cp -f .libs/sstream-inst-showmanyc.o sstream-inst-showmanyc.o +sstream-inst-showmanyc.o: sstream-inst-showmanyc.cc + $(CXXCOMPILE) -fPIC -DPIC -c $< + # Use special rules for the concept-checking instantiations so that all # the generated template functions are also instantiated. Force the checks # to be on so that the instantiations are actually seen. --- libstdc++-v3/include/std/std_sstream.h.jj 2004-10-04 14:58:25.000000000 +0200 +++ libstdc++-v3/include/std/std_sstream.h 2005-07-21 17:17:16.000000000 +0200 @@ -185,6 +185,18 @@ namespace std _M_sync(const_cast(_M_string.data()), 0, __len); } + virtual streamsize + showmanyc() + { + streamsize __ret = -1; + if (_M_mode & ios_base::in) + { + _M_update_egptr(); + __ret = this->egptr() - this->gptr(); + } + return __ret; + } + // [documentation is inherited] virtual int_type underflow(); --- libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc.jj 2003-10-01 12:12:11.000000000 +0200 +++ libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc 2005-07-22 01:22:15.000000000 +0200 @@ -45,7 +45,7 @@ void test03() std::streamsize d1 = strb_01.in_avail(); std::streamsize d2 = strb_03.in_avail(); VERIFY( d1 ); // non-zero - VERIFY( !d2 ); // zero, cuz ios_base::out + VERIFY( d2 == -1 ); // -1, cuz ios_base::out VERIFY( d1 != d2 ); //these should be the same VERIFY( static_cast(str_01.length()) == d1 ); VERIFY( strb_01.str() == strb_03.str() ); //ditto --- libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc.jj 2003-10-01 12:12:10.000000000 +0200 +++ libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc 2005-07-22 01:22:04.000000000 +0200 @@ -49,8 +49,8 @@ void test04() VERIFY( strmof_1 == static_cast(str_01.length()) ); VERIFY( strmof_2 == static_cast(str_02.length()) ); strmof_1 = strb_03.in_avail(); - // zero cuz write-only, or eof()? zero, from showmany - VERIFY( strmof_1 == 0 ); + // zero cuz write-only, or eof() to match basic_filebuf + VERIFY( strmof_1 == -1 ); } int main() --- libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc.jj 2005-07-22 01:22:04.000000000 +0200 +++ libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc 2005-07-22 01:22:04.000000000 +0200 @@ -0,0 +1,54 @@ +// 2005-06-07 Benjamin Kosnik + +// Copyright (C) 2005 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include +#include +#include + +double +test_stringstream() +{ + double result; + char* source = "1918"; + std::stringstream s; + s << source; + + std::string tmp = s.str(); + std::streambuf* sb = s.rdbuf(); + int i = sb->in_avail(); + + if (i) + { + s >> result; + } + else + { + throw std::runtime_error("conversion failed"); + } + return result; +} + + +int main () +{ + test_stringstream(); + return 0; +} --- libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc.jj 2005-07-22 01:21:41.000000000 +0200 +++ libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc 2005-07-22 01:21:41.000000000 +0200 @@ -0,0 +1,54 @@ +// 2005-06-07 Benjamin Kosnik + +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include +#include + +typedef std::basic_streambuf streambuf_type; + +struct testbuf : streambuf_type +{ + testbuf() { } +}; + +void test05() +{ + typedef streambuf_type::int_type int_type; + typedef streambuf_type::traits_type traits_type; + typedef streambuf_type::pos_type pos_type; + typedef streambuf_type::off_type off_type; + typedef size_t size_type; + + bool test __attribute__((unused)) = true; + std::streamoff strmof_1, strmof_2; + testbuf sb01; + + // int in_avail() + strmof_1 = sb01.in_avail(); + VERIFY( strmof_1 == 0 ); +} + +int main() +{ + test05(); + return 0; +} --- libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc.jj 2005-07-22 01:21:41.000000000 +0200 +++ libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc 2005-07-22 01:21:41.000000000 +0200 @@ -0,0 +1,54 @@ +// 2005-06-07 Benjamin Kosnik + +// Copyright (C) 2005 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include +#include + +typedef std::basic_streambuf streambuf_type; + +struct testbuf : streambuf_type +{ + testbuf() { } +}; + +void test05() +{ + typedef streambuf_type::int_type int_type; + typedef streambuf_type::traits_type traits_type; + typedef streambuf_type::pos_type pos_type; + typedef streambuf_type::off_type off_type; + typedef size_t size_type; + + bool test __attribute__((unused)) = true; + std::streamoff strmof_1, strmof_2; + testbuf sb01; + + // int in_avail() + strmof_1 = sb01.in_avail(); + VERIFY( strmof_1 == 0 ); +} + +int main() +{ + test05(); + return 0; +} --- libstdc++-v3/testsuite/lib/libstdc++.exp.jj 2005-05-06 12:59:10.000000000 +0200 +++ libstdc++-v3/testsuite/lib/libstdc++.exp 2005-07-22 10:03:52.000000000 +0200 @@ -283,6 +283,7 @@ proc v3_target_compile { source dest typ # Link the support objects into executables. if { $type == "executable" } { set cxx_final [concat $cxx_final ${v3-test_objs}] + lappend options "libs=-lstdc++_nonshared" } lappend options "compiler=$cxx_final"