This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PCH support on Solaris
> > gives the same address for both guess and size? That is, that Solaris
> > completely ignores the first argument unless MAP_FIXED is given?
>
> It appears so, indeed.
>
> > If so, my idea is useless at least under Solaris.
>
> No, it is not useless under Solaris
It's me who's lost now. :-) If I understand it correctly, you are saying that on one
hand giving mmi.preferred_base to the /dev/zero memory mapping is useless, on the other
hand it "just works". This is playing with fire about as much as the current, not
working, code; you should really use Ulrich's idea. You choose whether to embed my
heuristic in the following snippet.
#ifdef HAVE_MINCORE
/* We can make sure that MAP_FIXED is safe */
int flags = MAP_FIXED|MAP_SHARED;
char *vec = alloca ((mmi.size + pagesize - 1) / pagesize);
int result = mincore (mmi.preferred_base, mmi.size, vec);
if (result == -1)
{
warning ("PCH not usable");
return;
}
#else
/* We cannot make sure that MAP_FIXED is safe, just
use some common sense. It might be possible to try
to test the availability of a region at mmi.preferred_base
by using a non-fixed anonymous mmap, but this is not
bulletproof because the OS might just choose to ignore
the first argument when MAP_FIXED is not used. */
int flags = MAP_SHARED;
#endif
addr = mmap (mmi.preferred_base, mmi.size,
PROT_READ, flags, fd, mmi.offset);
if (addr != mmi.preferred_base)
{
assert (addr == -1);
if (addr == (void *) -1)
perror ("mmaping precompiled header");
warning ("PCH not usable");
return;
}
/* ok, mmap done */
|_ _ _ __
|_)(_)| ),'
------- '---