From cc58dead4c79b88653b57b3b7a8088cd8e08ed46 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Wed, 30 Jul 2025 15:12:11 -0400 Subject: [PATCH] Cast the 'addr' argument of 'madvise()' to match the AIX function signature in the 'libc' crate. --- src/sys/mman.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 867d207da3..bbb97f128b 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -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) } }