Commit 8eb6a092 by Eric Botcazou Committed by Eric Botcazou

re PR pch/9830 (PCH not working on Solaris)

	PR pch/9830
	* ggc-common.c (HAVE_MMAP_FILE): Include sys/types.h
	if HAVE_MINCORE is defined.
	(MAP_FAILED): Define if not defined.
	(gt_pch_save): Test against MAP_FAILED.
	(gt_pch_restore): If HAVE_MINCORE, use MAP_FIXED to force
	the mapping address to the preferred base after checking it
	is possible to do so. Test against MAP_FAILED.
	* configure.in: Test for the presence of mincore in libc.
	* config.in: Regenerate.
	* configure: Regenerate.

From-SVN: r67614
parent 22362755
2003-06-07 Eric Botcazou <ebotcazou@libertysurf.fr>
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
PR pch/9830
* ggc-common.c (HAVE_MMAP_FILE): Include sys/types.h
if HAVE_MINCORE is defined.
(MAP_FAILED): Define if not defined.
(gt_pch_save): Test against MAP_FAILED.
(gt_pch_restore): If HAVE_MINCORE, use MAP_FIXED to force
the mapping address to the preferred base after checking it
is possible to do so. Test against MAP_FAILED.
* configure.in: Test for the presence of mincore in libc.
* config.in: Regenerate.
* configure: Regenerate.
2003-06-07 Richard Henderson <rth@redhat.com> 2003-06-07 Richard Henderson <rth@redhat.com>
* config/alpha/alpha.c (alpha_setup_incoming_varargs): Fix * config/alpha/alpha.c (alpha_setup_incoming_varargs): Fix
......
...@@ -165,6 +165,9 @@ ...@@ -165,6 +165,9 @@
/* Define if you have the mempcpy function. */ /* Define if you have the mempcpy function. */
#undef HAVE_MEMPCPY #undef HAVE_MEMPCPY
/* Define if you have the mincore function. */
#undef HAVE_MINCORE
/* Define if you have the mmap function. */ /* Define if you have the mmap function. */
#undef HAVE_MMAP #undef HAVE_MMAP
......
...@@ -3726,7 +3726,7 @@ fi ...@@ -3726,7 +3726,7 @@ fi
for ac_func in times clock dup2 kill getrlimit setrlimit atoll atoq \ for ac_func in times clock dup2 kill getrlimit setrlimit atoll atoq \
sysconf strsignal putc_unlocked fputc_unlocked fputs_unlocked \ sysconf strsignal putc_unlocked fputc_unlocked fputs_unlocked \
fwrite_unlocked fprintf_unlocked getrusage nl_langinfo lstat \ fwrite_unlocked fprintf_unlocked getrusage nl_langinfo lstat \
scandir alphasort gettimeofday mbstowcs wcswidth mmap scandir alphasort gettimeofday mbstowcs wcswidth mmap mincore
do do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3733: checking for $ac_func" >&5 echo "configure:3733: checking for $ac_func" >&5
......
...@@ -797,7 +797,7 @@ dnl gcc_AC_C_ENUM_BF_UNSIGNED ...@@ -797,7 +797,7 @@ dnl gcc_AC_C_ENUM_BF_UNSIGNED
AC_CHECK_FUNCS(times clock dup2 kill getrlimit setrlimit atoll atoq \ AC_CHECK_FUNCS(times clock dup2 kill getrlimit setrlimit atoll atoq \
sysconf strsignal putc_unlocked fputc_unlocked fputs_unlocked \ sysconf strsignal putc_unlocked fputc_unlocked fputs_unlocked \
fwrite_unlocked fprintf_unlocked getrusage nl_langinfo lstat \ fwrite_unlocked fprintf_unlocked getrusage nl_langinfo lstat \
scandir alphasort gettimeofday mbstowcs wcswidth mmap) scandir alphasort gettimeofday mbstowcs wcswidth mmap mincore)
if test x$ac_cv_func_mbstowcs = xyes; then if test x$ac_cv_func_mbstowcs = xyes; then
AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works, AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
......
...@@ -36,6 +36,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -36,6 +36,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifdef HAVE_MMAP_FILE #ifdef HAVE_MMAP_FILE
# include <sys/mman.h> # include <sys/mman.h>
# ifdef HAVE_MINCORE
/* This is on Solaris. */
# include <sys/types.h>
# endif
#endif
#ifndef MAP_FAILED
# define MAP_FAILED ((void *)-1)
#endif #endif
#ifdef ENABLE_VALGRIND_CHECKING #ifdef ENABLE_VALGRIND_CHECKING
...@@ -449,7 +457,7 @@ gt_pch_save (FILE *f) ...@@ -449,7 +457,7 @@ gt_pch_save (FILE *f)
mmi.preferred_base = mmap (NULL, mmi.size, mmi.preferred_base = mmap (NULL, mmi.size,
PROT_READ | PROT_WRITE, MAP_PRIVATE, PROT_READ | PROT_WRITE, MAP_PRIVATE,
fileno (state.f), 0); fileno (state.f), 0);
if (mmi.preferred_base == (void *)-1) if (mmi.preferred_base == MAP_FAILED)
mmi.preferred_base = NULL; mmi.preferred_base = NULL;
else else
munmap (mmi.preferred_base, mmi.size); munmap (mmi.preferred_base, mmi.size);
...@@ -567,10 +575,41 @@ gt_pch_restore (FILE *f) ...@@ -567,10 +575,41 @@ gt_pch_restore (FILE *f)
addr = mmap (mmi.preferred_base, mmi.size, addr = mmap (mmi.preferred_base, mmi.size,
PROT_READ | PROT_WRITE, MAP_PRIVATE, PROT_READ | PROT_WRITE, MAP_PRIVATE,
fileno (f), mmi.offset); fileno (f), mmi.offset);
#else
addr = (void *)-1; #if HAVE_MINCORE
#endif if (addr != mmi.preferred_base)
if (addr == (void *)-1) {
size_t page_size = getpagesize();
char one_byte;
if (addr != MAP_FAILED)
munmap (addr, mmi.size);
/* We really want to be mapped at mmi.preferred_base
so we're going to resort to MAP_FIXED. But before,
make sure that we can do so without destroying a
previously mapped area, by looping over all pages
that would be affected by the fixed mapping. */
errno = 0;
for (i = 0; i < mmi.size; i+= page_size)
if (mincore ((char *)mmi.preferred_base + i, page_size, (void *)&one_byte) == -1
&& errno == ENOMEM)
continue; /* The page is not mapped. */
else
break;
if (i >= mmi.size)
addr = mmap (mmi.preferred_base, mmi.size,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED,
fileno (f), mmi.offset);
}
#endif /* HAVE_MINCORE */
#else /* HAVE_MMAP_FILE */
addr = MAP_FAILED;
#endif /* HAVE_MMAP_FILE */
if (addr == MAP_FAILED)
{ {
addr = xmalloc (mmi.size); addr = xmalloc (mmi.size);
if (fseek (f, mmi.offset, SEEK_SET) != 0 if (fseek (f, mmi.offset, SEEK_SET) != 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment