madvise() not declared if _XOPEN_SOURCE defined
The declaration of madvise() in sys/mman.h is conditional, and will not be declared in a default environment. This forces projects to explicitly declare this function, with the addutuibak complication that you need to pick the signature in a way that is compatible with solaris, as the two operating systems are indistinguishable based on preprocessor defines.
https://reviews.llvm.org/D119695#inline-1144987 suggests that Solaris 11.4 fixed this by using something like this:
#if !defined(XOPEN_OR_POSIX) || defined(__EXTENSIONS)
extern int madvise(void *, size_t, int);
extern int madvise(caddr_t, size_t, int);
The suggestion there is that Illumos adopt something similar.
The expected outcome is that if you include <sys/mman.h> without any additional defines, an madvise() declaration becomes available.
Updated by Robert Mustacchi 6 months ago
- Category set to headers
- Status changed from New to Duplicate
- Assignee set to Robert Mustacchi
We're working on this in #14418. Right now that will eliminate the older prototype and will fix some of the visibility issues. We're sorting out some issues with symbol visibility fallout and expectations through pkgsrc bulk builds, but I'm going to close this a duplicate of that.