From cbff8302355717eb3f73457f19538972443e36af Mon Sep 17 00:00:00 2001 From: Charles Samborski Date: Tue, 28 Aug 2018 15:48:58 +0200 Subject: [PATCH 1/2] Fix link in README.md (Rust operator precedence) --- library/compiler-builtins/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/compiler-builtins/README.md b/library/compiler-builtins/README.md index d10b44f8f782..cae885279ad1 100644 --- a/library/compiler-builtins/README.md +++ b/library/compiler-builtins/README.md @@ -69,13 +69,13 @@ features = ["c"] ### Porting Reminders -1. [Rust][4] and [C][5] have slightly different operator precedence. C evaluates comparisons (`== !=`) before bitwise operations (`& | ^`), while Rust evaluates the other way. +1. [Rust][5a] and [C][5b] have slightly different operator precedence. C evaluates comparisons (`== !=`) before bitwise operations (`& | ^`), while Rust evaluates the other way. 2. C assumes wrapping operations everywhere. Rust panics on overflow when in debug mode. Consider using the [Wrapping][6] type or the explicit [wrapping_*][7] functions where applicable. 3. Note [C implicit casts][8], especially integer promotion. Rust is much more explicit about casting, so be sure that any cast which affects the output is ported to the Rust implementation. 4. Rust has [many functions][9] for integer or floating point manipulation in the standard library. Consider using one of these functions rather than porting a new one. -[4]: https://doc.rust-lang.org/reference.html#operator-precedence -[5]: http://en.cppreference.com/w/c/language/operator_precedence +[5a]: https://doc.rust-lang.org/reference/expressions.html#expression-precedence +[5b]: http://en.cppreference.com/w/c/language/operator_precedence [6]: https://doc.rust-lang.org/core/num/struct.Wrapping.html [7]: https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_add [8]: http://en.cppreference.com/w/cpp/language/implicit_conversion From 1b4201f90d4c796c5776c1fb7ef077fb73af7f43 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 30 Aug 2018 14:13:15 -0700 Subject: [PATCH 2/2] Fix compilation on riscv32 --- library/compiler-builtins/src/riscv32.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/compiler-builtins/src/riscv32.rs b/library/compiler-builtins/src/riscv32.rs index ebaa354a4b30..9161a11ccecc 100644 --- a/library/compiler-builtins/src/riscv32.rs +++ b/library/compiler-builtins/src/riscv32.rs @@ -1,7 +1,8 @@ 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 { + pub extern "C" fn __mulsi3(a: u32, b: u32) -> u32 { + let (mut a, mut b) = (a, b); let mut r: usize = 0; while a > 0 {