Commit 4acab94b by Alexandre Oliva Committed by Alexandre Oliva

aclocal.m4 (AC_FUNC_MMAP_ZERO): New macro.

* aclocal.m4 (AC_FUNC_MMAP_ZERO): New macro.
* configure.in (AC_FUNC_MMAP_ZERO): Use instead of AC_FUNC_MMAP.
* ggc-page.c: Replace HAVE_MMAP with HAVE_MMAP_ZERO.
* configure, config.in: Rebuilt.

From-SVN: r31444
parent 08439bec
2000-01-16 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
* aclocal.m4 (AC_FUNC_MMAP_ZERO): New macro.
* configure.in (AC_FUNC_MMAP_ZERO): Use instead of AC_FUNC_MMAP.
* ggc-page.c: Replace HAVE_MMAP with HAVE_MMAP_ZERO.
* configure, config.in: Rebuilt.
2000-01-16 Zack Weinberg <zack@wolery.cumb.org> 2000-01-16 Zack Weinberg <zack@wolery.cumb.org>
* config/i386/i386.md: Add peephole to merge successive stack * config/i386/i386.md: Add peephole to merge successive stack
......
...@@ -680,3 +680,85 @@ else ...@@ -680,3 +680,85 @@ else
fi fi
AC_SUBST($1)dnl AC_SUBST($1)dnl
]) ])
# Check whether mmap can map an arbitrary page from /dev/zero, without
# MAP_FIXED.
AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
[AC_CHECK_HEADERS(unistd.h)
AC_CHECK_FUNCS(getpagesize)
AC_CACHE_CHECK(for working mmap from /dev/zero, ac_cv_func_mmap_zero,
[AC_TRY_RUN([
/* Test by Richard Henderson and Alexandre Oliva.
Check whether mmap from /dev/zero works. */
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
/* This mess was copied from the GNU getpagesize.h. */
#ifndef HAVE_GETPAGESIZE
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Assume that all systems that can run configure have sys/param.h. */
# ifndef HAVE_SYS_PARAM_H
# define HAVE_SYS_PARAM_H 1
# endif
# ifdef _SC_PAGESIZE
# define getpagesize() sysconf(_SC_PAGESIZE)
# else /* no _SC_PAGESIZE */
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# ifdef EXEC_PAGESIZE
# define getpagesize() EXEC_PAGESIZE
# else /* no EXEC_PAGESIZE */
# ifdef NBPG
# define getpagesize() NBPG * CLSIZE
# ifndef CLSIZE
# define CLSIZE 1
# endif /* no CLSIZE */
# else /* no NBPG */
# ifdef NBPC
# define getpagesize() NBPC
# else /* no NBPC */
# ifdef PAGESIZE
# define getpagesize() PAGESIZE
# endif /* PAGESIZE */
# endif /* no NBPC */
# endif /* no NBPG */
# endif /* no EXEC_PAGESIZE */
# else /* no HAVE_SYS_PARAM_H */
# define getpagesize() 8192 /* punt totally */
# endif /* no HAVE_SYS_PARAM_H */
# endif /* no _SC_PAGESIZE */
#endif /* no HAVE_GETPAGESIZE */
int main()
{
char *x;
int fd, pg;
fd = open("/dev/zero", O_RDWR);
if (fd < 0)
exit(1);
pg = getpagesize();
x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
if (x == (char *) -1)
exit(2);
*(int *)x += 1;
if (munmap(x, pg) < 0)
exit(3);
exit(0);
}], ac_cv_func_mmap_anywhere=yes, ac_cv_func_mmap_anywhere=no,
ac_cv_func_mmap_anywhere=no)])
if test $ac_cv_func_mmap_anywhere = yes; then
AC_DEFINE(HAVE_MMAP_ANYWHERE, 1,
[Define if mmap can get us zeroed pages from /dev/zero.])
fi
])
...@@ -415,3 +415,7 @@ ...@@ -415,3 +415,7 @@
/* Define if you have the i library (-li). */ /* Define if you have the i library (-li). */
#undef HAVE_LIBI #undef HAVE_LIBI
/* Define if mmap can get us zeroed pages from /dev/zero. */
#undef HAVE_MMAP_ANYWHERE
...@@ -405,7 +405,7 @@ case "${host}" in ...@@ -405,7 +405,7 @@ case "${host}" in
;; ;;
esac esac
AC_FUNC_VFORK AC_FUNC_VFORK
AC_FUNC_MMAP AC_FUNC_MMAP_ANYWHERE
GCC_NEED_DECLARATIONS(bcopy bzero bcmp \ GCC_NEED_DECLARATIONS(bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof strerror getcwd getwd \ index rindex getenv atol sbrk abort atof strerror getcwd getwd \
...@@ -4578,9 +4578,8 @@ AC_ARG_WITH(gc, ...@@ -4578,9 +4578,8 @@ AC_ARG_WITH(gc,
AC_MSG_ERROR([$withval is an invalid option to --with-gc]) AC_MSG_ERROR([$withval is an invalid option to --with-gc])
;; ;;
esac], esac],
[if test $ac_cv_func_mmap_fixed_mapped = yes; then [if test $ac_cv_func_mmap_anywhere = yes \
GGC=ggc-page || test $ac_cv_func_valloc = yes; then
elif test $ac_cv_func_valloc = yes; then
GGC=ggc-page GGC=ggc-page
else else
GGC=ggc-simple GGC=ggc-simple
......
/* "Bag-of-pages" garbage collector for the GNU compiler. /* "Bag-of-pages" garbage collector for the GNU compiler.
Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "flags.h" #include "flags.h"
#include "ggc.h" #include "ggc.h"
#ifdef HAVE_MMAP #ifdef HAVE_MMAP_ANYWHERE
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
...@@ -229,7 +229,7 @@ static struct globals ...@@ -229,7 +229,7 @@ static struct globals
unsigned char context_depth; unsigned char context_depth;
/* A file descriptor open to /dev/zero for reading. */ /* A file descriptor open to /dev/zero for reading. */
#if defined (HAVE_MMAP) && !defined(MAP_ANONYMOUS) #if defined (HAVE_MMAP_ANYWHERE) && !defined(MAP_ANONYMOUS)
int dev_zero_fd; int dev_zero_fd;
#endif #endif
...@@ -408,7 +408,7 @@ alloc_anon (pref, size) ...@@ -408,7 +408,7 @@ alloc_anon (pref, size)
{ {
char *page; char *page;
#ifdef HAVE_MMAP #ifdef HAVE_MMAP_ANYWHERE
#ifdef MAP_ANONYMOUS #ifdef MAP_ANONYMOUS
page = (char *) mmap (pref, size, PROT_READ | PROT_WRITE, page = (char *) mmap (pref, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
...@@ -430,7 +430,7 @@ alloc_anon (pref, size) ...@@ -430,7 +430,7 @@ alloc_anon (pref, size)
exit(1); exit(1);
} }
#endif /* HAVE_VALLOC */ #endif /* HAVE_VALLOC */
#endif /* HAVE_MMAP */ #endif /* HAVE_MMAP_ANYWHERE */
/* Remember that we allocated this memory. */ /* Remember that we allocated this memory. */
G.bytes_mapped += size; G.bytes_mapped += size;
...@@ -533,7 +533,7 @@ free_page (entry) ...@@ -533,7 +533,7 @@ free_page (entry)
static void static void
release_pages () release_pages ()
{ {
#ifdef HAVE_MMAP #ifdef HAVE_MMAP_ANYWHERE
page_entry *p, *next; page_entry *p, *next;
char *start; char *start;
size_t len; size_t len;
...@@ -579,7 +579,7 @@ release_pages () ...@@ -579,7 +579,7 @@ release_pages ()
free (p); free (p);
} }
#endif /* HAVE_VALLOC */ #endif /* HAVE_VALLOC */
#endif /* HAVE_MMAP */ #endif /* HAVE_MMAP_ANYWHERE */
G.free_pages = NULL; G.free_pages = NULL;
} }
...@@ -794,7 +794,7 @@ init_ggc () ...@@ -794,7 +794,7 @@ init_ggc ()
G.pagesize = getpagesize(); G.pagesize = getpagesize();
G.lg_pagesize = exact_log2 (G.pagesize); G.lg_pagesize = exact_log2 (G.pagesize);
#if defined (HAVE_MMAP) && !defined(MAP_ANONYMOUS) #if defined (HAVE_MMAP_ANYWHERE) && !defined(MAP_ANONYMOUS)
G.dev_zero_fd = open ("/dev/zero", O_RDONLY); G.dev_zero_fd = open ("/dev/zero", O_RDONLY);
if (G.dev_zero_fd == -1) if (G.dev_zero_fd == -1)
abort (); abort ();
...@@ -808,7 +808,7 @@ init_ggc () ...@@ -808,7 +808,7 @@ init_ggc ()
G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED; G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
#ifdef HAVE_MMAP #ifdef HAVE_MMAP_ANYWHERE
/* StunOS has an amazing off-by-one error for the first mmap allocation /* StunOS has an amazing off-by-one error for the first mmap allocation
after fiddling with RLIMIT_STACK. The result, as hard as it is to after fiddling with RLIMIT_STACK. The result, as hard as it is to
believe, is an unaligned page allocation, which would cause us to believe, is an unaligned page allocation, which would cause us to
......
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