From eaec0856625da0a163e7f4e0e226335ace1f9b2e Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 15 Mar 2018 09:41:01 +0100 Subject: [PATCH] Don't use libc with wasm32-unknown-unknown (#27) --- Cargo.toml | 4 +++- src/hash.rs | 6 +++--- src/lib.rs | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 722dd5f..0e19b1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,13 @@ description = "Fixed-size hashes" [dependencies] heapsize = { version = "0.4", optional = true } -libc = { version = "0.2", optional = true, default-features = false } rand = { version = "0.4", optional = true } rustc-hex = { version = "1.0", optional = true } quickcheck = { version = "0.6", optional = true } +[target.'cfg(not(target_os = "unknown"))'.dependencies] +libc = { version = "0.2", optional = true, default-features = false } + [features] default = ["libc"] std = ["rustc-hex", "rand"] diff --git a/src/hash.rs b/src/hash.rs index f02c59d..b5a0dfa 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -418,7 +418,7 @@ macro_rules! impl_std_for_hash_internals { ($from: ident, $size: tt) => {} } -#[cfg(feature="libc")] +#[cfg(all(feature="libc", not(target_os = "unknown")))] #[macro_export] #[doc(hidden)] macro_rules! impl_heapsize_for_hash { @@ -431,7 +431,7 @@ macro_rules! impl_heapsize_for_hash { } } -#[cfg(feature="libc")] +#[cfg(all(feature="libc", not(target_os = "unknown")))] #[macro_export] #[doc(hidden)] macro_rules! impl_libc_for_hash { @@ -453,7 +453,7 @@ macro_rules! impl_libc_for_hash { } } -#[cfg(not(feature="libc"))] +#[cfg(any(not(feature="libc"), target_os = "unknown"))] #[macro_export] #[doc(hidden)] macro_rules! impl_libc_for_hash { diff --git a/src/lib.rs b/src/lib.rs index 77d9f0d..50d5892 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature="libc")] +#[cfg(all(feature="libc", not(target_os = "unknown")))] #[doc(hidden)] pub extern crate libc;