Mail Archives: djgpp-workers/2000/05/11/09:42:58
> Btw, how is this implemented on Unix/Linux? Here's the relevant
> fragment from the test program run by Grep's configure script:
>
> fd = open("conftestmmap", O_RDWR);
> if (fd < 0)
> exit(1);
> data2 = malloc(2 * pagesize);
> if (!data2)
> exit(1);
> data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
> if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
> MAP_PRIVATE | MAP_FIXED, fd, 0L))
> exit(1);
>
> This expects mmap to return the same address as malloc did (modulo the
> alignment). Since, as DJ explained, mmap uses specially-mapped memory
> that can be grown at will without relocating, does this mean that mmap
> has to fiddle with the page tables to move the buffer to another
> physical address while keeping its logical address unchanged?
But Solaris' man page says:
"The use of MAP_FIXED is discouraged, as it may prevent an
implementation from making the most effective use of system
resources."
I also saw a similar statement on Linux.
So it's strange that a test for mmap() uses a feature that is
discouraged!
Right,
MartinS
- Raw text -