This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][LTO] Fix host portability issues with mmap and sysconf
On Thu, 1 Oct 2009, Richard Guenther wrote:
> On Thu, 1 Oct 2009, Andrew Pinski wrote:
>
> > On Thu, Oct 1, 2009 at 7:14 AM, Richard Guenther <rguenther@suse.de> wrote:
> > > + Â file = fdopen (file_data->fd, "r");
> > > + Â if (file == NULL
> > > + Â Â Â || fseek (file, offset, SEEK_SET) != 0
> > > + Â Â Â || fread (result, 1, len, file) != len)
> > > + Â Â {
> > > + Â Â Â free (result);
> > > + Â Â Â close (file_data->fd);
> > > + Â Â Â return NULL;
> > > + Â Â }
> >
> > I don't know how portable fdopen is but can't you use lseek and read
> > directly instead? FILE have an extra buffer intween the descriptor
> > and function calls.
>
> Well read/lseek seem to be less portable, at least nothing in gcc
> uses them (apart from mips-tfile.c). I could probably use fopen,
> but let's do that if there are actual problems.
>
> Oh, and of course I don't care for performance at all.
Ok, gcc.c unconditionally uses open/read/close - so lseek should be
ok as well. I'll move over to that.
Richard.