Revised test case (was Re: Who understands this code?)

Greg Schafer gschafer at
Fri Mar 14 07:33:43 PST 2003

On Sat, Mar 15, 2003 at 01:29:56AM +1100, Greg Schafer wrote:
> On Fri, Mar 14, 2003 at 03:20:42PM +0100, Ronald Hummelink wrote:
> > Right now, i'm going to step back to before glibc-ch5 and build it
> > without --enable-kernel=2.4.0 to see if it makes a difference.
> > Will let know about wether it does or not.
> Thanks for all that. I'll analyse tomorrow when my brain is working again :)
> I just finished the rebuild without --enable-kernel and no difference so
> don't bother :-/

Attached is a distilled test case that may make it clearer for anyone

Please note that this is not a huge drama, as the result of the autoconf
tests in question just sets these 2 defines in autohost.h:-

/* Define if mmap can get us zeroed pages from /dev/zero. */

/* Define if mmap can get us zeroed pages using MAP_ANON(YMOUS). */
#define HAVE_MMAP_ANON 1

which affect ggc-page.c (gcc's garbage collection... again). So the garbage
collection will still work but not optimally.

* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
   file open.  Prefer either to valloc.  */

It just pisses me off coz I'm so close to accounting for every single byte
in a complete LFS build and this problem is causing the gcc binaries to

-------------- next part --------------
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

/* Some versions of cygwin mmap require that munmap is called with the
   same parameters as mmap.  GCC expects that this is not the case.
   Test for various forms of this problem.  Warning - icky signal games.  */

static size_t pg;

static char *
anonmap (size)
     size_t size;
  return (char *) mmap (0, size, PROT_READ|PROT_WRITE,

/* 3. If we map two adjacent 1-page regions and unmap them both with
   one munmap, both must go away.

   Getting two adjacent 1-page regions with two mmap calls is slightly
   tricky.  All OS's tested skip over already-allocated blocks; therefore
   we have been careful to unmap all allocated regions in previous tests.
   HP/UX allocates pages backward in memory.  No OS has yet been observed
   to be so perverse as to leave unmapped space between consecutive calls
   to mmap.  */

static void
test_3 ()
  char *x, *y, *z;

  x = anonmap (pg);
  y = anonmap (pg);

  if (y != x + pg)
      if (y == x - pg)
	z = y, y = x, x = z;
	  fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
		   (unsigned long)x, (unsigned long)y);
	  exit (16);

main ()
  pg = getpagesize ();



More information about the lfs-dev mailing list