Skip to content

Commit 368c895

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

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
@@ -32,6 +32,8 @@ const MIN_ALIGN: usize = 8;
3232
target_arch = "powerpc64le")))]
3333
const MIN_ALIGN: usize = 16;
3434

35+
const MALLOCX_ZERO: c_int = 0x40;
36+
3537
// MALLOCX_ALIGN(a) macro
3638
fn mallocx_align(a: usize) -> c_int {
3739
a.trailing_zeros() as c_int
@@ -51,6 +53,12 @@ pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
5153
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
5254
}
5355

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

0 commit comments

Comments
 (0)