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

pluto--- via Discussion list for the autoconf build system <[email protected]> Wed, 31 Jul 2024 15:39:54 -0700
Newsgroups gmane.comp.sysutils.autoconf.general
Message-ID <66aabd3a.SomnGDYaxbCpjvEn%[email protected]>
"Yury V. Zaytsev" <[email protected]> wrote:

>  ...
>  bash-5.1$ gcc mmap-full.c
>  bash-5.1$ export XPG_SUS_ENV=ON
>  bash-5.1$ ./a.out
>  bash-5.1$ echo $?
>  0
>  bash-5.1$ unset XPG_SUS_ENV
>  bash-5.1$ ./a.out
>  bash-5.1$ echo $?
>  10
>
> ... all controlled by a variable at runtime
> ... nothing one can do at the build time, only runtime control.

Never say never :)

One could, at build time, include code to do something like (untested):

  if (strcmp(getenv("XPG_SUS_ENV", "ON")) != 0)
  {
    setenv("XPG_SUS_ENV", "ON", 1);
  }

(and yes, if AIX has already tested XPG_SUS_ENV before this gets
control, it might also be necessary for the program to re-exec
itself).

> ... for my use case, it's better to just get rid of mmap altogether.

Indeed.