Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2655.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cast the 'addr' argument of 'madvise()' to '*mut u8' on AIX to match the signature in the AIX libc.
17 changes: 15 additions & 2 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,22 @@ pub unsafe fn madvise(
length: size_t,
advise: MmapAdvise,
) -> Result<()> {
let ptr = {
// The AIX signature of 'madvise()' differs from the POSIX specification,
// which expects 'void *' as the type of the 'addr' argument, whereas AIX uses
// 'caddr_t' (i.e., 'char *').
#[cfg(target_os = "aix")]
{
addr.as_ptr() as *mut u8
}
#[cfg(not(target_os = "aix"))]
{
addr.as_ptr()
}
};

unsafe {
Errno::result(libc::madvise(addr.as_ptr(), length, advise as i32))
.map(drop)
Errno::result(libc::madvise(ptr, length, advise as i32)).map(drop)
}
}

Expand Down