Browse Source

Fix the abi hack on windows

Alex Crichton 7 years ago
parent
commit
12a0038250
2 changed files with 15 additions and 25 deletions
  1. 0 18
      src/lib.rs
  2. 15 7
      src/macros.rs

+ 0 - 18
src/lib.rs

@@ -78,24 +78,6 @@ macro_rules! urem {
     }
 }
 
-// Hack for LLVM expectations for ABI on windows
-#[cfg(all(windows, target_pointer_width="64"))]
-#[repr(simd)]
-pub struct U64x2(u64, u64);
-
-#[cfg(all(windows, target_pointer_width="64"))]
-fn conv(i: u128) -> U64x2 {
-    use int::LargeInt;
-    U64x2(i.low(), i.high())
-}
-
-#[cfg(all(windows, target_pointer_width="64"))]
-fn sconv(i: i128) -> U64x2 {
-    use int::LargeInt;
-    let j = i as u128;
-    U64x2(j.low(), j.high())
-}
-
 #[cfg(test)]
 extern crate core;
 

+ 15 - 7
src/macros.rs

@@ -110,13 +110,21 @@ macro_rules! intrinsics {
         $($rest:tt)*
     ) => (
         #[cfg(all(windows, target_pointer_width = "64"))]
-        intrinsics! {
-            $(#[$attr])*
-            pub extern $abi fn $name( $($argname: $ty),* )
-                -> ::macros::win64_abi_hack::U64x2
-            {
-                let e: $ret = { $($body)* };
-                ::macros::win64_abi_hack::U64x2::from(e)
+        $(#[$attr])*
+        pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
+            $($body)*
+        }
+
+        #[cfg(all(windows, target_pointer_width = "64"))]
+        pub mod $name {
+
+            intrinsics! {
+                pub extern $abi fn $name( $($argname: $ty),* )
+                    -> ::macros::win64_abi_hack::U64x2
+                {
+                    let e: $ret = super::$name($($argname),*);
+                    ::macros::win64_abi_hack::U64x2::from(e)
+                }
             }
         }