This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [committed] Fix PR pch/14940 on hppa hpux and linux


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]