[PATCH, gfortran] g77's FNUM, STAT, FSTAT, and FLUSH intrinsics

Janne Blomqvist jblomqvi@cc.hut.fi
Wed Nov 24 21:44:00 GMT 2004


On Wed, Nov 24, 2004 at 08:53:56AM -0800, Steve Kargl wrote:

Hi, just yet another small trivial nitpick..

> ChangeLog for libgfortran:
> 
>         * io/unix.c: Move comment to top, move struct unix_stream to ...
>         * io/unix.h: ... here

Hmm, I think the idea is that unix_stream should be contained within
unix.c.

>         * io/unix.c (fd_flush): unstaticize

See below.

> ===================================================================
> RCS file: /cvsroot/gcc/gcc/libgfortran/io/io.h,v
> retrieving revision 1.10
> diff -u -b -u -r1.10 io.h
> --- io/io.h	31 Aug 2004 14:06:48 -0000	1.10
> +++ io/io.h	24 Nov 2004 16:45:55 -0000
> @@ -465,6 +465,7 @@
>  #define flush prefix(flush)
>  try flush (stream *);

Here we already have a prototype for a function to flush a stream. It
is implemented in unix.c and is essentially just a wrapper around
fd_flush.

> Index: io/unix.c
> ===================================================================
> RCS file: /cvsroot/gcc/gcc/libgfortran/io/unix.c,v
> retrieving revision 1.13
> diff -u -b -u -r1.13 unix.c
> --- io/unix.c	30 Oct 2004 16:23:23 -0000	1.13
> +++ io/unix.c	24 Nov 2004 16:45:55 -0000

>  /* fd_flush()-- Write bytes that need to be written */
>  
> -static try
> +try
>  fd_flush (unix_stream * s)
>  {

... so it's not necessary to make fd_flush non-static, just use flush
instead. IIRC the reason that I made the flush wrapper (when I made
the iolength thingy in June), which essentially just typecasts the
stream to a unix_stream and calls fd_flush was that unix.c contains
unixisms and the design of the io library is AFAIK supposed to be such
that it is possible to drop in a replacement for some non-unixy
platform (see e.g. the distinction between stream and
unix_stream). Also, for the same reasons I think that unix_stream is
supposed to be used only inside unix.c. Typecasting a stream to
unix_stream is safe as long as the stream_alloc (or whatever they were
called) functions are used to allocate streams (in fact, they allocate
unix_streams behind the covers).

-- 
Janne Blomqvist



More information about the Gcc-patches mailing list