From 8d1467d91c6aa102682a0e84e286c66386074ae3 Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 6 Jan 2025 18:07:08 +0000 Subject: [PATCH] Fix cfgs --- src/ffi/c.rs | 56 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/ffi/c.rs b/src/ffi/c.rs index 226fe0e3..eeca73ef 100644 --- a/src/ffi/c.rs +++ b/src/ffi/c.rs @@ -50,27 +50,38 @@ impl Default for StreamWrapper { reserved: 0, opaque: ptr::null_mut(), state: ptr::null_mut(), - #[cfg(all( - feature = "any_zlib", - not(any(feature = "cloudflare-zlib-sys", feature = "libz-rs-sys")) + + #[cfg(any( + // zlib-ng + feature = "zlib-ng", + // libz-sys + all(not(feature = "cloudflare_zlib"), not(feature = "zlib-ng"), not(feature = "zlib-rs")) ))] zalloc: allocator::zalloc, - #[cfg(all( - feature = "any_zlib", - not(any(feature = "cloudflare-zlib-sys", feature = "libz-rs-sys")) + #[cfg(any( + // zlib-ng + feature = "zlib-ng", + // libz-sys + all(not(feature = "cloudflare_zlib"), not(feature = "zlib-ng"), not(feature = "zlib-rs")) ))] zfree: allocator::zfree, - #[cfg(all(feature = "any_zlib", feature = "cloudflare-zlib-sys"))] + #[cfg( + // cloudflare-zlib + all(feature = "cloudflare_zlib", not(feature = "zlib-rs"), not(feature = "zlib-ng")), + )] zalloc: Some(allocator::zalloc), - #[cfg(all(feature = "any_zlib", feature = "cloudflare-zlib-sys"))] + #[cfg( + // cloudflare-zlib + all(feature = "cloudflare_zlib", not(feature = "zlib-rs"), not(feature = "zlib-ng")), + )] zfree: Some(allocator::zfree), // for zlib-rs, it is most efficient to have it provide the allocator. // The libz-rs-sys dependency is configured to use the rust system allocator - #[cfg(all(feature = "any_zlib", feature = "libz-rs-sys"))] + #[cfg(all(feature = "zlib-rs", not(feature = "zlib-ng")))] zalloc: None, - #[cfg(all(feature = "any_zlib", feature = "libz-rs-sys"))] + #[cfg(all(feature = "zlib-rs", not(feature = "zlib-ng")))] zfree: None, })), } @@ -87,7 +98,14 @@ impl Drop for StreamWrapper { } } -#[cfg(all(feature = "any_zlib", not(feature = "libz-rs-sys")))] +#[cfg(any( + // zlib-ng + feature = "zlib-ng", + // cloudflare-zlib + all(feature = "cloudflare_zlib", not(feature = "zlib-rs"), not(feature = "zlib-ng")), + // libz-sys + all(not(feature = "cloudflare_zlib"), not(feature = "zlib-ng"), not(feature = "zlib-rs")), +))] mod allocator { use super::*; @@ -405,17 +423,19 @@ mod c_backend { #[cfg(feature = "zlib-ng")] use libz_ng_sys as libz; - #[cfg(all(not(feature = "zlib-ng"), feature = "zlib-rs"))] + #[cfg(all(feature = "zlib-rs", not(feature = "zlib-ng")))] use libz_rs_sys as libz; - #[cfg(all(not(feature = "zlib-ng"), feature = "cloudflare_zlib"))] + #[cfg( + // cloudflare-zlib + all(feature = "cloudflare_zlib", not(feature = "zlib-rs"), not(feature = "zlib-ng")), + )] use cloudflare_zlib_sys as libz; - #[cfg(all( - not(feature = "cloudflare_zlib"), - not(feature = "zlib-ng"), - not(feature = "zlib-rs") - ))] + #[cfg( + // libz-sys + all(not(feature = "cloudflare_zlib"), not(feature = "zlib-ng"), not(feature = "zlib-rs")), + )] use libz_sys as libz; pub use libz::deflate as mz_deflate;