|
@@ -13,6 +13,66 @@
|
|
// NOTE cfg(all(feature = "c", ..)) indicate that compiler-rt provides an arch optimized
|
|
// NOTE cfg(all(feature = "c", ..)) indicate that compiler-rt provides an arch optimized
|
|
// implementation of that intrinsic and we'll prefer to use that
|
|
// implementation of that intrinsic and we'll prefer to use that
|
|
|
|
|
|
|
|
+macro_rules! udiv {
|
|
|
|
+ ($a:expr, $b:expr) => {
|
|
|
|
+ unsafe {
|
|
|
|
+ let a = $a;
|
|
|
|
+ let b = $b;
|
|
|
|
+
|
|
|
|
+ if b == 0 {
|
|
|
|
+ intrinsics::abort()
|
|
|
|
+ } else {
|
|
|
|
+ intrinsics::unchecked_div(a, b)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+macro_rules! sdiv {
|
|
|
|
+ ($sty:ident, $a:expr, $b:expr) => {
|
|
|
|
+ unsafe {
|
|
|
|
+ let a = $a;
|
|
|
|
+ let b = $b;
|
|
|
|
+
|
|
|
|
+ if b == 0 || (b == -1 && a == $sty::min_value()) {
|
|
|
|
+ intrinsics::abort()
|
|
|
|
+ } else {
|
|
|
|
+ intrinsics::unchecked_div(a, b)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+macro_rules! urem {
|
|
|
|
+ ($a:expr, $b:expr) => {
|
|
|
|
+ unsafe {
|
|
|
|
+ let a = $a;
|
|
|
|
+ let b = $b;
|
|
|
|
+
|
|
|
|
+ if b == 0 {
|
|
|
|
+ intrinsics::abort()
|
|
|
|
+ } else {
|
|
|
|
+ intrinsics::unchecked_rem(a, b)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+macro_rules! srem {
|
|
|
|
+ ($sty:ty, $a:expr, $b:expr) => {
|
|
|
|
+ unsafe {
|
|
|
|
+ let a = $a;
|
|
|
|
+ let b = $b;
|
|
|
|
+
|
|
|
|
+ if b == 0 || (b == -1 && a == $sty::min_value()) {
|
|
|
|
+ intrinsics::abort()
|
|
|
|
+ } else {
|
|
|
|
+ intrinsics::unchecked_rem(a, b)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
#[cfg(test)]
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
#[macro_use]
|
|
extern crate quickcheck;
|
|
extern crate quickcheck;
|