Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
rust-lang/rust#40409 requires a __rust_alloc_zeroed function.
  • Loading branch information
kmindg committed May 24, 2017
1 parent aaf071d commit f916af3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const MIN_ALIGN: usize = 8;
target_arch = "powerpc64le")))]
const MIN_ALIGN: usize = 16;

const MALLOCX_ZERO: c_int = 0x40;

// MALLOCX_ALIGN(a) macro
fn mallocx_align(a: usize) -> c_int {
a.trailing_zeros() as c_int
Expand All @@ -52,6 +54,12 @@ pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
}

#[no_mangle]
pub extern "C" fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
let flags = align_to_flags(align) | MALLOCX_ZERO;
unsafe { ffi::mallocx(size as size_t, flags) as *mut u8 }
}

#[no_mangle]
pub extern "C" fn __rust_reallocate(ptr: *mut u8,
_old_size: usize,
Expand Down

0 comments on commit f916af3

Please sign in to comment.