Skip to content

Commit

Permalink
Merge pull request #251 from riscv-rust/master
Browse files Browse the repository at this point in the history
Implement __mulsi3.
  • Loading branch information
alexcrichton authored Aug 3, 2018
2 parents 52a6a4d + 6dcbd85 commit 5a7b58f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub mod arm;
#[cfg(all(kernel_user_helpers, target_os = "linux", target_arch = "arm"))]
pub mod arm_linux;

#[cfg(any(target_arch = "riscv32"))]
pub mod riscv32;

#[cfg(target_arch = "x86")]
pub mod x86;

Expand Down
17 changes: 17 additions & 0 deletions src/riscv32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
intrinsics! {
// Implementation from gcc
// https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c
pub extern "C" fn __mulsi3(mut a: u32, mut b: u32) -> u32 {
let mut r: usize = 0;

while a > 0 {
if a & 1 > 0 {
r += b;
}
a >>= 1;
b <<= 1;
}

r
}
}

0 comments on commit 5a7b58f

Please sign in to comment.