about summary refs log tree commit diff
path: root/src/libunwind
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-06-10 08:12:14 -0700
committerAlex Crichton <alex@alexcrichton.com>2019-06-10 10:58:44 -0700
commit8eb7f36a3ba06dbea4a44254c3e2d92455ae150f (patch)
tree713fd6d6cc498ca34a5292d574981b9240c1cc5f /src/libunwind
parenta73ecb3d9c432f8f53117b1a6b6c209dc802dee7 (diff)
std: Remove internal definitions of `cfg_if!` macro
This is duplicated in a few locations throughout the sysroot to work
around issues with not exporting a macro in libstd but still wanting it
available to sysroot crates to define blocks. Nowadays though we can
simply depend on the `cfg-if` crate on crates.io, allowing us to use it
from there!
Diffstat (limited to 'src/libunwind')
-rw-r--r--src/libunwind/Cargo.toml1
-rw-r--r--src/libunwind/lib.rs5
-rw-r--r--src/libunwind/libunwind.rs9
-rw-r--r--src/libunwind/macros.rs35
4 files changed, 5 insertions, 45 deletions
diff --git a/src/libunwind/Cargo.toml b/src/libunwind/Cargo.toml
index 4ddc878997e..f0f1bab425d 100644
--- a/src/libunwind/Cargo.toml
+++ b/src/libunwind/Cargo.toml
@@ -19,6 +19,7 @@ doc = false
 core = { path = "../libcore" }
 libc = { version = "0.2.43", features = ['rustc-dep-of-std'], default-features = false }
 compiler_builtins = "0.1.0"
+cfg-if = "0.1.8"
 
 [build-dependencies]
 cc = { optional = true, version = "1.0.1" }
diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
index 0ccffea3170..9182e349b19 100644
--- a/src/libunwind/lib.rs
+++ b/src/libunwind/lib.rs
@@ -11,10 +11,7 @@
 
 #![cfg_attr(not(target_env = "msvc"), feature(libc))]
 
-#[macro_use]
-mod macros;
-
-cfg_if! {
+cfg_if::cfg_if! {
     if #[cfg(target_env = "msvc")] {
         // no extra unwinder support needed
     } else if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs
index 339b554ed6a..5794e0b7683 100644
--- a/src/libunwind/libunwind.rs
+++ b/src/libunwind/libunwind.rs
@@ -1,10 +1,5 @@
 #![allow(nonstandard_style)]
 
-macro_rules! cfg_if {
-    ( $( if #[cfg( $meta:meta )] { $($it1:item)* } else { $($it2:item)* } )* ) =>
-        ( $( $( #[cfg($meta)] $it1)* $( #[cfg(not($meta))] $it2)* )* )
-}
-
 use libc::{c_int, c_void, uintptr_t};
 
 #[repr(C)]
@@ -82,7 +77,7 @@ extern "C" {
     pub fn _Unwind_GetDataRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr;
 }
 
-cfg_if! {
+cfg_if::cfg_if! {
 if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm"))))] {
     // Not ARM EHABI
     #[repr(C)]
@@ -206,7 +201,9 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm
         pc
     }
 }
+} // cfg_if!
 
+cfg_if::cfg_if! {
 if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
     // Not 32-bit iOS
     extern "C" {
diff --git a/src/libunwind/macros.rs b/src/libunwind/macros.rs
deleted file mode 100644
index 659e977285e..00000000000
--- a/src/libunwind/macros.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-/// A macro for defining `#[cfg]` if-else statements.
-///
-/// This is similar to the `if/elif` C preprocessor macro by allowing definition
-/// of a cascade of `#[cfg]` cases, emitting the implementation which matches
-/// first.
-///
-/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
-/// without having to rewrite each clause multiple times.
-macro_rules! cfg_if {
-    ($(
-        if #[cfg($($meta:meta),*)] { $($it:item)* }
-    ) else * else {
-        $($it2:item)*
-    }) => {
-        __cfg_if_items! {
-            () ;
-            $( ( ($($meta),*) ($($it)*) ), )*
-            ( () ($($it2)*) ),
-        }
-    }
-}
-
-macro_rules! __cfg_if_items {
-    (($($not:meta,)*) ; ) => {};
-    (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => {
-        __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* }
-        __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* }
-    }
-}
-
-macro_rules! __cfg_if_apply {
-    ($m:meta, $($it:item)*) => {
-        $(#[$m] $it)*
-    }
-}