This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] Use getc/putc instead of fgetc/fputc
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Apr 2007 07:50:08 -0400
- Subject: Re: [Patch, fortran] Use getc/putc instead of fgetc/fputc
- References: <462F3AB1.1080300@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Apr 25, 2007 at 02:25:37PM +0300, Janne Blomqvist wrote:
> :ADDPATCH fortran:
>
> the attached patch converts the gfortran frontend to use getc/putc
> instead of fgetc/fputc.
>
> In normal cases there's no difference, but in pathological cases like
> e.g. the example program from PR21130 this patch shaves about 5-10s of
> the 90s runtime.
>
> I also tried to use the _unlocked stdio functions, but there was no
> difference. It seems the build system is clever enough to substitute the
> _unlocked versions automatically when building a single-threaded program.
Look at gcc/system.h, which if configure detects e.g. getc_unlocked
it redefines getc for use in gcc as getc_unlocked etc.
The difference is most probably just in getc_unlocked being implemented
inline, whereas fgetc_unlocked is not.
Jakub