Skip to content

Commit f916af3

Browse files
committed
Fix test failure
rust-lang/rust#40409 requires a __rust_alloc_zeroed function.
1 parent aaf071d commit f916af3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const MIN_ALIGN: usize = 8;
3333
target_arch = "powerpc64le")))]
3434
const MIN_ALIGN: usize = 16;
3535

36+
const MALLOCX_ZERO: c_int = 0x40;
37+
3638
// MALLOCX_ALIGN(a) macro
3739
fn mallocx_align(a: usize) -> c_int {
3840
a.trailing_zeros() as c_int
@@ -52,6 +54,12 @@ pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
5254
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
5355
}
5456

57+
#[no_mangle]
58+
pub extern "C" fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
59+
let flags = align_to_flags(align) | MALLOCX_ZERO;
60+
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
61+
}
62+
5563
#[no_mangle]
5664
pub extern "C" fn __rust_reallocate(ptr: *mut u8,
5765
_old_size: usize,

0 commit comments

Comments
 (0)