This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [committed] Fix PR pch/14940 on hppa hpux and linux
- From: Richard Henderson <rth at redhat dot com>
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Nov 2004 20:41:19 -0800
- Subject: Re: [committed] Fix PR pch/14940 on hppa hpux and linux
- References: <200411300325.iAU3PPci028297@hiauly1.hia.nrc.ca>
On Mon, Nov 29, 2004 at 10:25:25PM -0500, John David Anglin wrote:
> + addr = mmap (base, size, PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> +
> + if (addr != base)
> + return -1;
> +
> + faddr = mmap (NULL, size, PROT_READ, MAP_PRIVATE,
> + fd, offset);
> +
> + if (faddr == (void *) MAP_FAILED)
> + return -1;
> +
> + memcpy (addr, faddr, size);
> + munmap (faddr, size);
I suspect that it'll actually be faster to read(2) the data into
the anonymous map than using mmap/memcpy/munmap. You've really
got to have more than one sequential access to data in order to
amortize the overhead of the mapping.
r~