diff options
author | (no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-04-12 13:58:36 +0000 |
---|---|---|
committer | (no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-04-12 13:58:36 +0000 |
commit | ed65ca0b85c6812ecb8e11aa57c413fbb263f02f (patch) | |
tree | 827289e88a38b2feb9e008634508c7883a2250c3 | |
parent | f82f8a41e72d54a572998a1ecc5b86400c673b33 (diff) | |
download | gcc-ed65ca0b85c6812ecb8e11aa57c413fbb263f02f.tar.gz |
This commit was manufactured by cvs2svn to create branch
'gcc-3_4-branch'.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branch@80622 138bc75d-0d04-0410-961f-82ee72b054a4
24 files changed, 738 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/unify5.C b/gcc/testsuite/g++.dg/template/unify5.C new file mode 100644 index 00000000000..6928f1f8429 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/unify5.C @@ -0,0 +1,10 @@ + +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Apr 2004 <nathan@codesourcery.com> +// Origin:Matt Austern <austern@apple.com> + +// PR:c++/14007 + +template <typename T> struct X {}; // #1 +template <typename T> struct X<const T>; //#2 +template struct X<int&>; //#3 diff --git a/gcc/testsuite/g++.dg/template/unify6.C b/gcc/testsuite/g++.dg/template/unify6.C new file mode 100644 index 00000000000..ee6a8ce0fdb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/unify6.C @@ -0,0 +1,22 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Apr 2004 <nathan@codesourcery.com> + +void Baz (); + +template <typename T> void Foo1 (T *); // #1 +template <typename T> void Foo1 (T const *a) {a (1);} // #2 + +template <typename T> T const *Foo2 (T *); + +template <typename T> void Foo3 (T *, T const * = 0); + +void Bar () +{ + Foo1 (&Baz); // #1 + + Foo2 (&Baz); + + Foo3 (&Baz); + + Foo3 (&Baz, &Baz); // { dg-error "no matching function" "" } +} diff --git a/gcc/testsuite/g++.dg/template/unify7.C b/gcc/testsuite/g++.dg/template/unify7.C new file mode 100644 index 00000000000..3f7028b642f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/unify7.C @@ -0,0 +1,14 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Apr 2004 <nathan@codesourcery.com> + +// PR c++/3518 +template <typename T> void Foo (const T &); +template <typename T> void Baz (const T (*)()); + +int &f (); + +int main() +{ + Foo (f); + Baz (f); // { dg-error "no matching function" "" } +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c new file mode 100644 index 00000000000..d6f9eff2563 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c new file mode 100644 index 00000000000..90738a7a7e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) + +#undef T + +void +struct_by_value_5a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf1, float) +T(Sf2, float) +T(Sf3, float) +T(Sf4, float) +T(Sf5, float) +T(Sf6, float) +T(Sf7, float) +T(Sf8, float) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c new file mode 100644 index 00000000000..9ac1f913474 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c new file mode 100644 index 00000000000..dcb5f27ed09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c new file mode 100644 index 00000000000..3c371558728 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) + +#undef T + +void +struct_by_value_5b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c new file mode 100644 index 00000000000..cedc1660709 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c new file mode 100644 index 00000000000..609c1d67308 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c new file mode 100644 index 00000000000..e6852d9c9b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) + +#undef T + +void +struct_by_value_6a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c new file mode 100644 index 00000000000..8684b53c2f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c new file mode 100644 index 00000000000..ff17221718f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c new file mode 100644 index 00000000000..5b285c9c5b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) + +#undef T + +void +struct_by_value_6b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c new file mode 100644 index 00000000000..c568761b241 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c new file mode 100644 index 00000000000..8379dc563c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c new file mode 100644 index 00000000000..9818c3c2251 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) + +#undef T + +void +struct_by_value_7a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sld1, long double) +T(Sld2, long double) +T(Sld3, long double) +T(Sld4, long double) +T(Sld5, long double) +T(Sld6, long double) +T(Sld7, long double) +T(Sld8, long double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c new file mode 100644 index 00000000000..cb53df89dac --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c new file mode 100644 index 00000000000..5d6908bfc1f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c new file mode 100644 index 00000000000..508ff616584 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) + +#undef T + +void +struct_by_value_7b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sld9, long double) +T(Sld10, long double) +T(Sld11, long double) +T(Sld12, long double) +T(Sld13, long double) +T(Sld14, long double) +T(Sld15, long double) +T(Sld16, long double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c new file mode 100644 index 00000000000..cc70a7d2925 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc new file mode 100644 index 00000000000..f187307afab --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/char/4.cc @@ -0,0 +1,59 @@ +// 2004-04-07 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004 Free Software Foundation +// +// 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. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<char> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + iterator_type end; + istringstream iss; + iss.imbue(loc_c); + const time_get<char>& tim_get = + use_facet<time_get<char> >(iss.getloc()); + + iss.str("Jul"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == 6 ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc new file mode 100644 index 00000000000..dd1c393ac15 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/time_get/get_monthname/wchar_t/4.cc @@ -0,0 +1,59 @@ +// 2004-04-07 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2004 Free Software Foundation +// +// 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. + +// 22.2.5.1.1 time_get members + +#include <locale> +#include <sstream> +#include <testsuite_hooks.h> + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + typedef istreambuf_iterator<wchar_t> iterator_type; + + const ios_base::iostate good = ios_base::goodbit; + ios_base::iostate errorstate = good; + + // basic construction + locale loc_c = locale::classic(); + + iterator_type end; + wistringstream iss; + iss.imbue(loc_c); + const time_get<wchar_t>& tim_get = + use_facet<time_get<wchar_t> >(iss.getloc()); + + iss.str(L"Jul"); + iterator_type is_it01(iss); + tm time01; + errorstate = good; + tim_get.get_monthname(is_it01, end, iss, errorstate, &time01); + VERIFY( time01.tm_mon == 6 ); + VERIFY( errorstate == ios_base::eofbit ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc b/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc new file mode 100644 index 00000000000..d40e0c25130 --- /dev/null +++ b/libstdc++-v3/testsuite/performance/27_io/filebuf_sputn_unbuf.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2004 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 <cstdio> +#include <fstream> +#include <testsuite_performance.h> + +// libstdc++/11378 +int main() +{ + using namespace std; + using namespace __gnu_test; + + time_counter time; + resource_counter resource; + + const int iterations = 500000; + const int chunksize = 100; + + char* chunk = new char[chunksize]; + + // C + FILE* file = fopen("tmp", "w+"); + setvbuf(file, 0, _IONBF, 0); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + fwrite(chunk, 1, chunksize, file); + stop_counters(time, resource); + fclose(file); + report_performance(__FILE__, "C", time, resource); + clear_counters(time, resource); + + // C unlocked + file = fopen("tmp", "w+"); + setvbuf(file, 0, _IONBF, 0); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + fwrite_unlocked(chunk, 1, chunksize, file); + stop_counters(time, resource); + fclose(file); + report_performance(__FILE__, "C unlocked", time, resource); + clear_counters(time, resource); + + // C++ + filebuf buf; + buf.pubsetbuf(0, 0); + buf.open("tmp", ios_base::out | ios_base::in | ios_base::trunc); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + buf.sputn(chunk, chunksize); + stop_counters(time, resource); + report_performance(__FILE__, "C++", time, resource); + + unlink("tmp"); + delete [] chunk; + + return 0; +} |