Skip to content

Commit

Permalink
Fix cfgs
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 6, 2025
1 parent 14aec22 commit 8d1467d
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions src/ffi/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})),
}
Expand All @@ -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::*;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8d1467d

Please sign in to comment.