[Patch, libgfortran] PR 25561 Part 0.9/2 Get rid of alloc stream

Janne Blomqvist blomqvist.janne@gmail.com
Mon May 5 22:08:00 GMT 2008


Hello,

this is an almost complete patch for part I of getting rid of the alloc
stream facility (the low level libgfortran I/O stuff). The patch
converts all users of salloc_* to the sread/swrite/sseek interface, with
the exception of write_x(). The exception is an issue with T/TL edit
descriptors, and as it turns out these don't work correctly now either,
see PR 36142. See the PR for some ideas on how to solve it.

After this patch and the T/TL fix is in, I plan to continue to part II,
which means to simplify the library by getting rid of the
{fd,mem}_alloc* functions. For external files (fd_*()) the main idea
I've been thinking about is to replace the current buffered I/O
implementation with C stdio. This would, IMHO, have the following benefits:

* Due to the extremely widespread usage of stdio, we can be quite sure
there are no bugs in the buffering. And even if there are, it's the
headache of the upstream libc. This is in contrast to our current
implementation that does plenty of flushing to cover up bugs.

* Better performance, stdio is mature and has been tweaked over many
years. Also lack of unnecessary flushing, see above.

* Well documented, with well defined semantics.

* When doing formatted reads, we must usually read one character at a
time. This has a huge overhead in our current implementation. It would
be relatively simple to use getc() here. Or actually getc_unlocked() if
available, since we would lock the stream for the duration of a
READ/WRITE statement (flockfile()/funlockfile()).

* Make life slightly easier for people doing mixed language programming,
since gfortran would use the same buffering as C. And C++ with
sync_with_stdio() or any other language whose runtime is implemented in
terms of stdio. Of course, mixed language I/O to the same file would
still be somewhat dangerous.

Patch is regtested on i686-pc-linux-gnu, ok for trunk?

-- 
Janne Blomqvist
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ChangeLog
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080505/2f23f812/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr25561-part09.diff
Type: text/x-patch
Size: 38540 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080505/2f23f812/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080505/2f23f812/attachment.sig>


More information about the Gcc-patches mailing list