Skip to content

Commit 5a7b58f

Browse files
authored
Merge pull request #251 from riscv-rust/master
Implement __mulsi3.
2 parents 52a6a4d + 6dcbd85 commit 5a7b58f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ pub mod arm;
5858
#[cfg(all(kernel_user_helpers, target_os = "linux", target_arch = "arm"))]
5959
pub mod arm_linux;
6060

61+
#[cfg(any(target_arch = "riscv32"))]
62+
pub mod riscv32;
63+
6164
#[cfg(target_arch = "x86")]
6265
pub mod x86;
6366

src/riscv32.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
intrinsics! {
2+
// Implementation from gcc
3+
// https://raw.githubusercontent.com/gcc-mirror/gcc/master/libgcc/config/epiphany/mulsi3.c
4+
pub extern "C" fn __mulsi3(mut a: u32, mut b: u32) -> u32 {
5+
let mut r: usize = 0;
6+
7+
while a > 0 {
8+
if a & 1 > 0 {
9+
r += b;
10+
}
11+
a >>= 1;
12+
b <<= 1;
13+
}
14+
15+
r
16+
}
17+
}

0 commit comments

Comments
 (0)