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

Christian Franke Christian.Franke@t-online.de
Mon Jul 6 17:08:16 GMT 2026


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.

-- 
Regards,
Christian



More information about the Cygwin mailing list