This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: PATCH: Avoid excessive flushing on lower-layer handle


>> I'm in the middle of testing this: I'll let you know linux results as
>> I finish.

> Loren, great job. You're cleared for check in with this patch.

> Would it be possible for you to add this scott synder test into
> 27_io/narrow_stream_objects.cc as a disabled, interactive test? It's
> silly to have to track this down all the time. Just put in the comment
> about expected output with redirection and without it to explain how to
> manually run the testcase.

Agreed, I meant to ask you where you wanted it.  Thanks for the
preemptive hint. ;-)

Committed to mainline (as previously posted) with these new test cases
as tested on i386-*-freebsd4.5 and elsewhere.  Now testing on branch
as required (I know it is approved, but I hadn't tested it personally
yet).  I will install there ASAP (within hours of now).

I agree with Jason's comments and will revisit this as a mainline-only
rework after the 3.1 release.

Regards,
Loren

	* include/std/std_fstream.h (basic_filebuf::sync): Hoist
	unconditional flush on lower-layer handle to here...
	* include/bits/fstream.tcc (basic_filebuf::_M_really_overflow):
	...from here.  Optimize remaining _M_file.sync() call pattern.
	* testsuite/27_io/narrow_stream_objects.cc (test04): New test.
	(test05): Likewise.

Index: testsuite/27_io/narrow_stream_objects.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc,v
retrieving revision 1.6
diff -c -r1.6 narrow_stream_objects.cc
*** testsuite/27_io/narrow_stream_objects.cc	7 Aug 2001 03:38:33 -0000	1.6
--- testsuite/27_io/narrow_stream_objects.cc	23 Apr 2002 23:38:26 -0000
***************
*** 113,118 ****
--- 113,150 ----
    cout << "i == " << i << endl;
  }
  
+ // Interactive test, to be exercised as follows:
+ // assign stderr to stdout in shell command line,
+ // pipe stdout to cat process and/or redirect stdout to file.
+ // "hello fine world\n" should be written to stdout in proper order.
+ // This is a version of the scott snyder test taken from:
+ // http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00108.html
+ void test04()
+ {
+   using namespace std;
+ 
+   cout << "hello ";
+   cout.flush ();
+   cerr << "fine ";
+   cerr.flush ();
+   cout << "world" << endl;
+   cout.flush ();
+ }
+ 
+ // Interactive test, to be exercised as follows:
+ // run test under truss(1) or strace(1).  Look at
+ // size and pattern of write system calls.
+ // Should be 2 or 3 write(1,[...]) calls when run interactively
+ // depending upon buffering mode enforced.
+ void test05()
+ {
+   std::cout << "hello" << ' ' << "world" <<std::endl;
+   std::cout << "Enter your name: ";
+   std::string s;
+   std::cin >> s;
+   std::cout << "hello " << s << std::endl;
+ }
+ 
  int 
  main()
  {
***************
*** 120,124 ****
--- 152,158 ----
  
    // test02();
    // test03();
+   // test04();
+   // test05();
    return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]