Re: AC_FUNC_MMAP test fails on AIX for MAP_FIXED: who's at fault?

Paul Eggert <[email protected]> Sun, 28 Jul 2024 22:20:01 -0700
Newsgroups gmane.comp.sysutils.autoconf.general
Organization UCLA Computer Science Department
Message-ID <[email protected]>
On 2024-07-28 15:40, Bob Friesenhahn wrote:

> Whoever wrote it had an expectation that it would be used for this 
> purpose.  It would be good to investigate the history of this macro to 
> see if its purpose was always the same or if its scope was later narrowed.

AC_FUNC_MMAP has always checked for MAP_FIXED, ever since it was 
introduced to Autoconf in 1994[1] by Mike Haertel and Jim Avera. Mike 
wrote in 2010[2] that he built GNU grep to use mmap for speed, so I 
think the Autoconf macro was for GNU grep, which did use MAP_FIXED. 
Although that sort of thing made sense on some platforms in the early 
1990s, I noticed even at the time that it actually made things slower in 
significant cases, and in 2010 Paolo Bonzini noticed something similar 
and removed mmap usage from GNU grep[3]. I've never been tempted to 
bring it back.

Because POSIX+XSI requires support for MAP_FIXED[4], it's reasonable for 
AC_FUNC_MMAP to check for MAP_FIXED, and AIX mmap should support 
MAP_FIXED if AIX says it conforms to XSI.

I suppose that an app that needs mmap but not MAP_FIXED (which is 
allowed by POSIX sans XSI) could write its own special-purpose Autoconf 
macro for that. That being said, if you're planning to use mmap on AIX 
good luck; you may need it[5].

[1]: 
https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=8202df5faf642cde4e5b1fa02cd9cc4411a7a477
[2]: 
https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html
[3]: 
https://git.savannah.gnu.org/cgit/grep.git/commit/?id=f17211efe374200d532a9f27173e15b018e5538e
[4]: 
https://pubs.opengroup.org/onlinepubs/9799919799/functions/mmap.html#tag_17_345_03
[5]: https://news.ycombinator.com/item?id=19805675