Cygwin madvise(): aliased to posix_madvise() but the error handling should differ

Mark Geisert mark@maxrnd.com
Mon Jul 6 22:44:35 GMT 2026


Hi Christian,

On 7/6/2026 10:08 AM, Christian Franke via Cygwin wrote:
> Currently madvise() appears only as an alias in cygwin.din:
> 
> madvise = posix_madvise SIGFE
> 
> But according to the man pages, the error handling should differ:
> 
> https://man7.org/linux/man-pages/man2/madvise.2.html:
> "On error, it returns -1 and errno is set to indicate the error."
> 
> https://man7.org/linux/man-pages/man3/posix_madvise.3.html
> "On failure, it returns a positive error number."
> 
> https://pubs.opengroup.org/onlinepubs/009695399/functions/ 
> posix_madvise.html
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/ 
> posix_madvise.html
> "... otherwise, an error number shall be returned to indicate the error."
> 
> The POSIX variant implies that 'errno' is left unchanged.
> 
> On Cygwin, only posix_madvise() works as documented.
> On Linux, both functions work as documented.

Thanks for the report and diagnosis.  I'll submit a patch shortly.

..mark


More information about the Cygwin mailing list