bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'fflush' test failure on Cygwin


From: Eric Blake
Subject: Re: 'fflush' test failure on Cygwin
Date: Fri, 13 Apr 2007 07:25:51 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 4/13/2007 4:15 AM:
> Eric Blake wrote:
>> I'm still worried, though, that after using
>> rpl_fflush/rpl_fseek, will fread/fgetc pick up at the correct character?
>> I hope not to rewrite the entire stdio.
> 
> This should be feasible, since a stream has a state when the buffer is empty
> and the file descriptor is not block-aligned: namely, early after program
> initialization. If you ensure that all internal pointers/counters are set
> according to this state, I don't expect that you would need to override
> fread(), fgetc(), etc.

OK, looking further at the newlib and MacOS sources (which I guess means
looking at the entire BSD family), I may have a solution that doesn't even
require rpl_fseek.  It looks like the optimized seek is bypassed if
fp->_seek is not __sseek, after possibly calling it once for SEEK_CUR.  So
I think what I do is make rpl_fflush check if fp->_seek is __sseek, in
which case I replace it with rpl_sseek.  rpl_sseek is written to call
__sseek, and to restore __sseek to fp->_seek if whence is not SEEK_CUR.
Then, fseek immediately following will be non-optimized, because it will
see the non-__sseek, but the optimization is restored following the fseek.

On cygwin, __sseek is not exported, so I can't do a configure time link
check for its existence.  Instead, rpl_sseek will have to be dropped in
for any non-NULL fp->_seek, and rpl_sseek is a bit more complicated
because it has to maintain a mapping of which _seek to use and restore
based on which fp (aka cookie) is passed in.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGH4Tf84KuGfSFAYARAoiPAJ95tus/XB5DW+Ho8cR0RttnQfdPKQCg0Tte
ghsZLsZE6CpK+zU/vZ5hIC0=
=OcqB
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]